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? Dustin, thinking the world would be a more interesting place if compiler writers actually produced such compilers _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On 04/20/2011 10:07 AM, Ahmed Charles wrote:> Technically, it could've sent the mail before you even thought about > writing it.As a some-time student of General Relativity, technically, no it couldn't. :-)> ...Undefined is undefined, there are no requirements.The question was about which noun "undefined" qualifies--is it the behavior of the compiler which is undefined, or merely the behavior of the compiler's output? I gather the answer may be the former, while I'd have guessed that it is merely the latter. I suppose one argument in favor of the answer being the former is that it is the more insane answer, and therefore a priori more likely to be the decision of the committee. :-) Not that it is greatly important that I know the answer, I guess, or I'd actually look it up. Dustin
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.
> 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.I don't think this is correct. The standard does not make much of a distinction between compile time and run time, there is merely a "C implementation."> For example, also, if you do `sizeof(i++ + i++)`, this behavior is perfectly > fine, and not undefined behavior. Because the `i++` is not evaluated.Probably also wrong. John