This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Fwd: gcc bug]
- To: "Derek R. Price" <derek dot price at openavenue dot com>
- Subject: Re: [Fwd: gcc bug]
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Tue, 17 Oct 2000 22:31:48 +0100 (BST)
- cc: gcc-bugs at gcc dot gnu dot org
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