From: SF/projects/mingw n. l. <min...@li...> - 2012-06-14 14:16:55
|
Bugs item #2819860, was opened at 2009-07-10 15:00 Message generated for change (Comment added) made by earnie You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=2819860&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: gcc Group: None >Status: Closed >Resolution: Out of Date Priority: 5 Private: No Submitted By: Anthony (anthonypenn) Assigned to: Nobody/Anonymous (nobody) Summary: Runtime crash when compiled under GCC 4.4.0 Initial Comment: Synopsis: --------------- I've recently switched compilation of my project to GCC 4.4.0 (from GCC 3.4.5) and the result is an odd and inconsistent runtime crash. I've narrowed it down to a switch statement (handling win32 API events); however after further investigation I've found that: - the runtime crash occurs when a certain case label is included in the switch - the value of the label is not the problem (I've tried arbitrary integers), the mere *presence of* the case seems to trigger the crash. - for the sake of testing, I have made the case completely empty and ensured it is never reached - the crash ONLY occurs when optimizations are enabled (-s -O3) The mere presence of a case that is never reached in a switch statement should theoretically have no effect, which has prompted me to recognize this as a bug in GCC 4.4.0. The project is large and no simple test case can be constructed. Given the nature of occurrence the entire project need be compiled to reproduce it; however from the inclusion/exclusion of an empty case statement that is never reached making the only make-or-break difference while compiling under optimizations, it seems that something is awry in the optimized code generated for switch statements). The observed bug can be summarized as this: switch( X ) { case SOME_LABEL: break; // inclusion of this case while compiling under GCC 4.4.0 with full optimizations causes the crash // whereas GCC 3.4.5 produces no such problem case PROBLEMATIC_LABEL_THAT_IS_EMPTY_AND_NEVER_REACHED: // break; } As mentioned above, I suspect optimizations in GCC 4.4.0 are producing code that is not robust for this case. If any more information is required, just let me know, I can provide entire source and makefile if need-be. Until further notice however, I will be compiling under GCC 3.4.5 so as to avoid this bug. Environment Information: ---------------------------------------- Windows XP (SP2) gcc --version: gcc (GCC) 4.4.0 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ld -v: GNU ld (GNU Binutils) 2.19.1 shell: cmd.exe (with compilation setup through mingw32-make) mingw32-make --version: GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for i686-pc-mingw32 ---------------------------------------------------------------------- >Comment By: Earnie Boyd (earnie) Date: 2012-06-14 07:16 Message: Optimization is a best guess by the compiler. It may require you to mark your code with a "do not optimize" marker. If you are still having problems with a more recent version of GCC please open a new issue. And we really must have a simple test case to help resolve the issues. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=2819860&group_id=2435 |