🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #764

integer value of multi-char constants

#764
From: David Lai
Date: Tue, 17 Oct 1989 02:43
30 lines
1433 bytes
Below is an example of a possible bug in various C compilers, it has to
do with converting multi-character constants to integer values:

on a mips, vax, and sun the following is true:

	'\001\377' == '\000\377';

however on the same machines:

	'\001\177' != '\000\177';

The question is: does the above behaviour conform to ANSI C?

In section 3.1.3.4, it states that the value of an integer character constant
containing of more than one char,..., is implementation defined.  So seemingly
it is legal to map all multi-char constants to random values, and the above
cases indicate a conforming behaviour.  But is it intuitive that the above two
expressions can co-exist together?

I beleive the bug (if it is a bug) is inherent in all pcc
implementations.  I would like to know if there are some C implementations
out there in which the above is not true.

If you want to try this on a sun(3), you will have to use:
	'\377\000' and '\377\001'
for unknown reasons.

-- 
        "What is a DJ if he can't scratch?"  - Uncle Jamms Army
     David Lai (lai@mips.com || {ames,prls,pyramid,decwrl}!mips!lai)
Technical Details
Message-ID: <29588@gumby.mips.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!apple!mips!lai

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!apple!mips!lai
From: lai@mips.COM (David Lai)
Newsgroups: comp.std.c
Subject: integer value of multi-char constants
Message-ID: <29588@gumby.mips.COM>
Date: 17 Oct 89 02:43:49 GMT
Lines: 30