Re: C FAQ 3.1



On Tue, 26 Apr 2005 12:04:15 +0000, Stan Milam wrote:

> Peter Nilsson wrote:
>> ccwork wrote:
>>
>>>Hi all,
>>
>>>Why can't it be unspecified?
>>
>>
>> The real question is: Why _should_ it be specified?
>>
>
> Because it would clear up a lot of confusion, specify exactly what the
> behavior should be. I am convinced we have undefined behavior because
> K&R were too lazy or in a hurry to specify exactly what should happen in
> these now undefined cases.

It is more likely because this freedom gives compilers extra scope for
optimisation. On some architectured the natural calling sequence might
favour left to right evaluation of arguments, on another ot might be right
to left. Some optimisers might find advantages in other arrangements. It
isn't that common for the order of evaluation to cause a problem so making
it unspecified is a reasonable choice.

Lawrence



.



Relevant Pages

  • Re: C FAQ 3.1
    ... I am convinced we have undefined behavior because ... > favour left to right evaluation of arguments, on another ot might be right ... With OOE processors and write-back memory caching, ... Should C compilers be forced to insert memory ...
    (comp.lang.c)
  • Re: Does this program exhibit undefined behaviour or output?
    ... thearg got progname ... Yes, the order of evaluation of arguments is not specified, so at the ... the order of argument evaluation without invoking undefined behavior. ...
    (comp.lang.c)
  • Re: C FAQ 3.1
    ... Regardless of the order of evaluation, ... Expressions ... It would only add to your confusion. ... Code which exhibits undefined behavior like that, ...
    (comp.lang.c)
  • sequence points and evaluation order
    ... Expression has undefined behavior (left operand uses errno, ... Code has unspecified behavior. ... different places not separated by a sequence point constraining evaluation ... Can t2num be assigned the value ...
    (comp.lang.c)
  • Re: Order of procedure argument eval?
    ... The optimizations allowed by the order of evaluation ... rules and expression evaluation rules are much too broad to ... I think that you mean there is no disagreement about ... global optimisation would be the cause. ...
    (comp.lang.fortran)

Loading