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]

[Bug c++/42810] Enumeration with sequential values has its for-loop exit condition optimized out.



------- Comment #20 from pinskia at gcc dot gnu dot org  2010-01-27 21:10 -------
(In reply to comment #19)
> Try:
Actually that code is defined as signed char++ is defined to be signed char =
(signed char) ((int)i + 1); by the C/C++ promotion rules.

#include <stdio.h>
main()
{
    for (signed i = 1 ; i >= -2 ; i++)
    {
        printf( "%d ", i);
    }
}

---- CUT ---
That will cause different behavior at different optimization levels.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42810


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