From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95) Description of problem: The following is incorrectly optimised under 2.96-85: (*s == *(++s)) Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1.Compile attached code with and without -O2 2.Compare the results of running 3. Actual Results: Result depends on whether the O2 option is specified Expected Results: Result should always be correct Additional info: This was under gcc 2.96-85
Created attachment 30114 [details] Simple demo of preincrement optimization error under gcc
Why do you think it is incorrectly optimized? ISO C does not require a sequence point after the left operand of == operator (see ISO C99 5.1.2.3, 6.5/3 and the whole ISO C99 Annex C), so gcc is allowed to evaluate the two operands to == operator in any order it wants.