[Bug sanitizer/68065] Size calculations for VLAs can overflow

danielmicay at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 11 00:37:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68065

--- Comment #21 from Daniel Micay <danielmicay at gmail dot com> ---
(In reply to joseph@codesourcery.com from comment #20)
> Undefined behavior when the type is created (not when an object of that 
> type is declared or when sizeof is used) seems entirely in accordance with 
> normal C practice in areas such as stack overflow[*] (that is, where the C 
> standard fails to recognize limits in such areas but all implementations 
> in practice have such limits, that's a defect in the C standard).

Stack overflow is undefined with GCC, but MSVC++ and Clang on Windows guarantee
that it will be caught if the program doesn't invoke any truly undefined
behavior. Clang will be getting an implementation for other platforms soon, and
it will probably end up being enabled by default since it really has no
significant overhead.

The implementation of -fstack-check in GCC does have significant overhead, but
it doesn't have to be that way. It shouldn't go out of the way to provide a
proper stack trace with -O2/-O3 (or whatever other reasons it has for the slow
implementation).


More information about the Gcc-bugs mailing list