[LLVMdev] Is this a bug in clang?
Johannes Schaub (litb)
schaub.johannes at googlemail.com
Wed Apr 20 11:16:12 PDT 2011
Ahmed Charles wrote:
> Technically, it could've sent the mail before you even thought about
> writing it. Undefined is undefined, there are no requirements. From:
> Dustin Laurence
> Sent: Wednesday, April 20, 2011 6:50 AM
> To: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] Is this a bug in clang?
> On 04/19/2011 10:50 PM, John Regehr wrote:
>> The compiler is perfectly within its rights to send a rude email to your
>> department chair if you compile that code.
> Wouldn't it technically be only within its rights to compile code that
> sends the rude email when executed, but not send the email itself? Or
> are the undefined results of compilation not confined to the contents of
> the executable file?
It's the evaluation of the expression "i++ + i++" that result in undefined
behavior. If you merely compile a program that contains the expression, the
expression is never evaluated. You need to execute the program to have the
expression be evaluated and behavior be undefined.
For example, also, if you do `sizeof(i++ + i++)`, this behavior is perfectly
fine, and not undefined behavior. Because the `i++` is not evaluated.
More information about the llvm-dev