This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c/10143: Post increment doesn work more than once per statement


Good point... I did not see that recommendation, however, even if I
had.... check this:


{macdonn}85: which gcc
/opt/unsupported/gcc-2.95.2/bin/gcc
{macdonn}86: gcc -Wall shift.c
shift.c: In function `main':
shift.c:67: warning: unsigned int format, long unsigned int arg (arg 4)
shift.c:68: warning: unsigned int format, long unsigned int arg (arg 4)
shift.c:70: warning: unsigned int format, long unsigned int arg (arg 4)
shift.c:71: warning: unsigned int format, long unsigned int arg (arg 3)
shift.c:72: warning: unsigned int format, long unsigned int arg (arg 4)
{macdonn}87: gcc -Wsequence-point shift.c
cc1: Invalid option `-Wsequence-point'


{macdonn}193: gcc -Wall WeirdForLoop.c        
{macdonn}194: gcc -v
Reading specs from
/tmp/gcc_install/lib/gcc-lib/sparc-sun-solaris2.8/3.2.2/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls --prefix=/tmp/gcc_install
Thread model: posix
gcc version 3.2.2
{macdonn}195: gcc -Wsequence-point WeirdForLoop.c

There is no sequence point warning when compiling either program... 
using either 2.95.2 or 3.2.2


As for your questions... I submitted by bug by starting from this URL:
http://www.gnu.org/directory/gcc.html which led to this URL:
http://www.gnu.org/software/gcc/gnats.html which led to this URL: 
http://gcc.gnu.org/cgi-bin/gnatsweb.pl  and no where along that path did
I see the recommendationabout warnings (even though in this case that
would not have helped.)


A person comment on all this:
I was just trying to make the product better...  I feel the answer of
"not a bug" to be a bit pedantic...  sure, technically it may not be a
bug...  however, logically, the current behaviour is less than stellar
and it should be addressed to make post and pre increment behave more or
less similarly...  I have learned a valuable lesson from all this, and I
will now write better code because of it... but I still think that the
choice of implementing this behaviour in the chosen manner is highly
likely to make a bad problem much more seriously wrong than it should
be.  (If the evil empire can do something meaningful with it...  we
should be able to learn from that...)

If this bizarre code generating behaviour is to stand as is then I'd
rather the compiler default to warning on this behaviour than to make it
my requirement to know that I should request a sequence point
warning...  i.e. default the warning on and make it a requirement to
supress it.

Nick


"Joseph S. Myers" wrote:
> 
> On 19 Mar 2003, Falk Hueffner wrote:
> 
> > > (Is there a FAQ entry somewhere that deals with this issue?)
> >
> > See the documentation of -Wsequence-point. (We should probably add
> > this to the list of C non-bugs...)
> 
> The bug reporting instructions <http://gcc.gnu.org/bugs.html> say:
> 
>    Before reporting that GCC compiles your code incorrectly, please
>    compile it with gcc -Wall and see whether this shows anything wrong
>    with your code that could be the cause instead of a bug in GCC.
> 
> To the submitter: did you see this part of the instructions and try
> compiling your code with -Wall (which includes -Wsequence-point, which
> would have shown up the problem with the code)?  If not, how could we
> improve the documentation of how to submit bugs so that you would have
> seen and followed these instructions?  If you did use -Wall, how could we
> clarify the warning message?
> 
> --
> Joseph S. Myers
> jsm28 at cam dot ac dot uk

-- 
Nick MacDonald
Nortel Networks, Belleville
macdonn at nortelnetworks dot com
(613) 966-0100 Ext. 8755  ESN: 343-8755


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]