Bogus warning from AIX XL C Compiler/6000?

Ken Lindahl 642-0866 lindahl at violet.berkeley.edu
Sat Aug 25 09:41:47 AEST 1990


In article <3239 at awdprime.UUCP> @cs.utexas.edu:ibmchs!auschs!woan.austin.ibm.com!ron writes:
>In article <1990Aug23.034343.11444 at murdoch.acc.Virginia.EDU>,
>mms7r at krebs.acc.Virginia.EDU (Mitch Smith) writes:
>Mitch> Problem: The character constant in the following short program
>Mitch> produces a bogus warning.
>Mitch> /* test1.c */ main() { 	int c;
>Mitch> 	c = '\x'; 	printf("c = %c\n", c); 	exit(0); }
>Mitch> ..............a..  a - 1506-235: (W) Illegal escape sequence x
>Mitch> ignored.  $
>
>Mitch> 	In fact, 'x' is not ignored.  When executed, the
>Mitch> compiled program prints "c = x".
>
[text deleted]
>
>Yes, get the new ANSI edition of K&R. On page 193: "If the character
>following the \ is not one of those specified, the behavior is
>undefined." And actually, 'x' just happens to have been defined for
>specifying constants in hex, i.e. '\x07' is the bell. You should thank
>your lucky stars that you got the right output or the fact that IBM
>has tried to be as backwards compatible as possible, so they only gave
>you a very good warning message with an indication of what it was
>going to do with it. Anyway, this doesn't seem like something you
>should be trying to do anyway, afterall what's wrong with c='x'?
>
Nit: I think a "very good warning message" should be more accurate, e.g.:
(W) Undefined escape sequence '\x'. Replaced by 'x'.

More importantly, this and an earlier posting referred to the '\xNN' escape
sequence, where NN is a hex number indexing the ASCII character set.
It seems to me that this should only apply to the situation where the '\x'
is followed by at least one character from the set [0123456789ABCDEF].
That is, '\x' should be treated like any other undefined, non-hex escape
sequence.  (Note this is exactly what the compiler has done. I'm not taking
issue with the compiler, but with the two postings.) If you try to interpret
'\x' as a hex escape, the only reasonable (?) interpretation is '\x00' and
the compiler should insert a NUL character. This is not a recommendation on
my part.

This probably ought to go to comp.lang.c.dementia, but I don't subscribe to
that newsgroup.

Ken Lindahl				lindahl at violet.berkeley.edu
Advanced Technology Planning,
Information Systems and Technology
University of California at Berkeley

P.S. to Mitch: You really should have recognized the problem as soon
as you saw the error number, "1506-235". :-)



More information about the Comp.unix.aix mailing list