[Bug c++/51270] constness violation is accepted without any warning but leads to a required function call being eliminated during optimization

2011-11-22 Thread michiel_dewilde at agilent dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51270 --- Comment #1 from Michiel De Wilde michiel_dewilde at agilent dot com 2011-11-22 15:26:42 UTC --- Created attachment 25885 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=25885 preprocessed source code (*.ii)

[Bug c++/51270] constness violation is accepted without any warning but leads to a required function call being eliminated during optimization

2011-11-22 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51270 --- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org 2011-11-22 15:47:45 UTC --- If you want warnings then you should request them using -Wall etc. Although doing so at -O2 gives this, which isn't actually very helpful: e.cpp:67:60:

[Bug c++/51270] constness violation is accepted without any warning but leads to a required function call being eliminated during optimization

2011-11-22 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51270 --- Comment #3 from Jonathan Wakely redi at gcc dot gnu.org 2011-11-22 15:50:33 UTC --- If you eliminate the obfuscation you get this: int* faulty_compiled_function(char* val) { char const* tmp = val; return (int*)tmp; } char* input =

[Bug c++/51270] constness violation is accepted without any warning but leads to a required function call being eliminated during optimization

2011-11-22 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51270 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Keywords||diagnostic ---