For this program, -O2 will create an infinite loop: int test=0; void main(void) { while((volatile int)test!=0); }
If "volatile int" is not allowed, there should be at least some warning or error, but it compiles successfully. -- Summary: Abnormal behavior in optimization Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lamshuyin at netvigator dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386 GCC host triplet: i386 GCC target triplet: ARM http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18314