This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[Fwd: Re: compiler interpretation of *mptr++ = mptr]
- From: Ajoy K Thamattoor <athamatt at cisco dot com>
- To: gcc at gcc dot gnu dot org
- Cc: erchrist at cisco dot com
- Date: Thu, 31 Mar 2005 14:28:42 -0800
- Subject: [Fwd: Re: compiler interpretation of *mptr++ = mptr]
A colleague of mine pointed out gcc gave warnings on the following
constructs.
I understand a strictly conforming implementation is allowed to warn on
anything,
but some of these are actually valid constructs. Wanted clarification on
why gcc
wants to provide sequence-point warnings on these. Please cc me on the
response,
since I am not subscribed to the list...
Thanks in advance,
Ajoy.
--
http://cs.stanford.edu/~ajoyk
a = a; /* { dg-bogus "undefined" "bogus sequence point warning" } */
There is no multiple modification here. Think of how similar this is to:
a = a + 1;
a = fn (a++); /* { dg-bogus "undefined" "bogus sequence point
warning" } */
A function call introduces a sequence point. Hence there is a
sequence point between
the two modifications of 'a' here.
b++, (b + b); /* { dg-bogus "undefined" "bogus sequence point
warning" } */
The comma operator introduces a sequence point. This is fully
equivalent to
b++; (b + b);
(a = b++), (a = b++); /* { dg-bogus "undefined" "bogus sequence point
warning" } */
Same thing. This is equivalent to (a = b++); (a = b++);
a = (b++, b++); /* { dg-bogus "undefined" "bogus sequence point
warning" } */
Same thing.
a = b++ && b++; /* { dg-bogus "undefined" "bogus sequence point
warning" } */
a = b++ || b++; /* { dg-bogus "undefined" "bogus sequence point
warning" } */
a = (b++ ? b++ : a); /* { dg-bogus "undefined" "bogus sequence point
warning" } */
The &&, || and ? operators introduce sequence points. The multiple
modifications
to 'b' here are separated by a sequence point, and these are valid.
a = (b++ ? a : b++); /* { dg-bogus "undefined" "bogus sequence point
warning" } */
Same here.