public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/8175: different behaviour with different optimization levels
@ 2002-10-09  8:36 Pierre.van.de.Laar_AT_Philips.com
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre.van.de.Laar_AT_Philips.com @ 2002-10-09  8:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8175
>Category:       optimization
>Synopsis:       different behaviour with different optimization levels
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 09 08:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Pierre.van.de.Laar_AT_Philips.com
>Release:        gcc version 2.95.3 20010315 (release)
>Organization:
>Environment:
unix
>Description:
The following (stupid, I admit) code is treated differently under different optimalizations (no warning or error is made)

#include <stdio.h>
int main(int argc, char * argv[])
{
	int i;
	/* use argc */
	i = argc;
	if (i++ == i++) 
	{
		printf("true %d\n",i);
	}
	else
	{
		printf("false %d\n",i);
	}
    return 0;
}
laarp@mollis [199] > gcc -Wall -O0 test.c
laarp@mollis [200] > a.out               
true 2
laarp@mollis [201] > gcc -Wall -O6 test.c
laarp@mollis [202] > a.out               
false 3

Note: This piece of code violates: an object shall have its stored value modified at most once by the evaluation of an expression
(Committee Draft -- August 3, 1998, WG14/N843 
paragraph 6.5 Expressions)
I don't know if it is still part of the the official release.
>How-To-Repeat:
Just compile the code and see for yourself!
>Fix:
Generate at least a warning or always have the same behaviour.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: optimization/8175: different behaviour with different optimization levels
@ 2002-10-11 16:19 rth
  0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-10-11 16:19 UTC (permalink / raw)
  To: Pierre.van.de.Laar_AT_Philips.com, gcc-bugs, gcc-prs, nobody

Synopsis: different behaviour with different optimization levels

State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Fri Oct 11 16:19:04 2002
State-Changed-Why:
    Not a bug.  Undefined behaviour: two modifications with
    no sequence point.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8175


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-11 23:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09  8:36 optimization/8175: different behaviour with different optimization levels Pierre.van.de.Laar_AT_Philips.com
2002-10-11 16:19 rth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).