[Bug sanitizer/68065] Size calculations for VLAs can overflow
ch3root at openwall dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 19 23:05:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68065
--- Comment #32 from Alexander Cherepanov <ch3root at openwall dot com> ---
Sorry for the late reply. Decided to read DR 260 and got distracted. It
so fundamentally undermines the base of classical C that it took me some
time to grasp the scale:-)
On 2015-11-12 01:51, joseph at codesourcery dot com wrote:
>> 4. From the POV of the standard I don't see much difference between VLA
>> and ordinary arrays in this question. AFAICT the standard doesn't place
>> limits on constructed types of any kind and hence oversized types are
>> permitted by the standard. See comment #3 (or pr68107) for a practical
>
> "permitted by" only in the sense of "the standard does not require
> implementations to reject them". It is not intended that the listed
> implementation limits are the only limits that there may be, at compile
> time or run time.
What does the following mean then?
C11, 4p5:
"A strictly conforming program[...] It [...] shall not exceed any
minimum implementation limit."
C11, 4p6:
"A conforming hosted implementation shall accept any strictly conforming
program."
>> 3. The same for sizes of objects. There is an environmental limit for
>> "bytes in an object" but it's marked as "(in a hosted environment
>> only)". So there is no such limit in the standard for a freestanding
>> implementation, right? But I doubt that you are supposed to be able to
>
> No, what's "in a hosted environment only" is the requirement that the
> implementation translate and execute some program with a 65535-byte object
> (and an instance of the other given limits, simultaneously); freestanding
> implementations may have an object size limit smaller than 65535 bytes.
> That is, effectively, C99 and above do not support hosted environments
> with a 16-bit address space; systems with a 16-bit address space are only
> supported for freestanding implementations.
I see, thanks for the info.
More information about the Gcc-bugs
mailing list