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++/44613] Declaring an array with non-constant length inside a switch corrupts stack pointer.



------- Comment #4 from manu at gcc dot gnu dot org  2010-06-21 16:51 -------
(In reply to comment #3)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > The following program compiles with g++ -O3 without errors or warnings
> > 
> > Not with warnings enabled it doesn't!
> > 
> 
> Sorry,
> 
> g++ -O3 -Wall -Wextra switch-crash.cpp gives:
> 
> switch-crash.cpp: In function ?int f(int)?:
> switch-crash.cpp:6: warning: unused variable ?x?
> switch-crash.cpp:10: warning: no return statement in function returning
> non-void

If you add return 0 after the printf, this warning is silenced and it still
crashes (it crashes for me even at -O0).

> switch-crash.cpp:7: warning: ?saved_stack.1? is used uninitialized in this
> function
> 
> The ?saved_stack.1? is somewhat suspicious. 

It is a bug anyway, because internal variables should never be warned.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-06-21 16:51:06
               date|                            |


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


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