[LLVMdev] Language lawyer question

Shantonu Sen ssen at apple.com
Wed Mar 12 00:23:45 PDT 2008


On Mar 11, 2008, at 10:52 PM, Dale Johannesen wrote:

>> I think the test case is bogus in terms of language correctness,
>
> Why?

My gut. I listen to my gut. More seriously, C99 section 6.2.6.1  
paragraph 6 has:

> When a value is stored in an object of structure or union type,  
> including in a member
> object, the bytes of the object representation that correspond to  
> anypadding bytes take
> unspeciļ¬ed values.42)

and the footnote says:

> 42) Thus, for example, structure assignment need not copyany padding  
> bits.

I think that covers this case for at least C99. The test case should  
not assume the padding bytes are copied.

If you assume "need not copy" semantics, the test case doesn't have  
much value for correctness. If you want LLVM to assume an  
implementation-specific "must copy" or "must not copy" behavior, you  
could tweak the test case as needed, I suppose. But under aggressive  
optimization, you rapidly approach "must copy" semantics, and then the  
question is why you don't do that for even the degenerate cases. So  
again, it turns into an optimization test case.

Shantonu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080312/a9121da4/attachment.html>


More information about the llvm-dev mailing list