[Fwd: gcc bug]

Joseph S. Myers jsm28@cam.ac.uk
Tue Oct 17 14:32:00 GMT 2000


On Tue, 17 Oct 2000, Derek R. Price wrote:

> Since subbing the tolower line with:
>
>     *p = tolower(*p);
>     p++;
>
> or
>
>     print ("%c", *p++);
>
> fails to produce a seg fault, I'm assuming this is a bug in gcc.

No, the problem is in your program; it fails to follow the sequence point
rules in the C standard.  Current GCC CVS will tell you about the problem
if you compile with -Wall:

tmp.c: In function `main':
tmp.c:10: warning: operation on `p' may be undefined
tmp.c:11: warning: control reaches end of non-void function

See the documentation of -Wsequence-point under
http://gcc.gnu.org/onlinedocs/gcc_2.html#SEC9 for more information.  
(Also, see Clive Feather's "Annex S" and Michael Norrish's thesis linked
to from there, subclause 6.3 of ISO/IEC 9899:1990, and subclause 6.5
paragraph 2 of ISO/IEC 9899:1999, if you want original sources or further
technical detail than is to be found in the GCC manual.)

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-bugs mailing list