[llvm-dev] Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")

Justin Bogner via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 26 00:33:54 PST 2016


Chandler Carruth <chandlerc at google.com> writes:
> On Thu, Feb 25, 2016 at 10:40 PM Justin Bogner via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>> I am *way* out of my depth here, but what if 'c' was an 'unsigned
>>> char' (and not an 'int')?  Wouldn't that prevent UB, since it is
>>> escaped (cannot be a register variable), and is an 'unsigned char'
>>> (doesn't have a trap representation)?
>> 
>> Nah, C's pretty explicit that using uninitialized locals is undefined
>> behaviour, regardless of type. From C11 J.2:
>> 
>>   The value of an object with automatic storage duration is used while
>>   it is indeterminate (6.2.4, 6.7.9, 6.8).
>> 
>> It's also stated in 6.2.4 that "the initial value of the object is
>> indeterminate."
>
> Reading an indeterminate value isn't UB in C. Even branching on it isn't.

Maybe not, but this is quite literally "[using] the value of an object
with automatic storage duration while it is indeterminate", unless
there's a very strange definition of use buried somewhere else in the
standard. This case is explicitly called out.


More information about the llvm-dev mailing list