http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49905
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 21:10:06 UTC --- Just use also -D_FORTIFY_SOURCE=1 -O2 or -D_FORTIFY_SOURCE=2 -O2. For the first three overflows on q you'll get compile time warnings, and for all overflows on q you'll get the program killed at runtime. If you use char * p = (char *) malloc (4); instead of char * p = new char [4]; you'll get protection for the p overflows too, I'll see if __builtin_object_size could be taught about C++ new, at least some forms thereof.