View Single Post
  #47  
Old February 27th, 2004, 02:13 AM

alexti alexti is offline
First Lieutenant
 
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
alexti is on a distinguished road
Default Re: 2.08 and Incompatible Battle Reports

Quote:
Originally posted by Arryn:
quote:
Originally posted by alexti:
The idea of the standards is to be able to write code which will work correctly (meaning that as programmer specified in the source code - as opposite to what the programmer wants ) if compiled by any standard-compliant compiler.
The C/C++ standards do not address the issue that's been the focus of this interminable discussion. So your argument is sort of irrelevant.
That's exactly the point. If C/C++ standard does not specify the order of evaluation (I haven't seen it there, but it doesn't mean that it's not there though ) you can not rely on any particular order.
In the following example you can't rely on whether left call or right call will be evaluated first, but you can rely that both of them will be evaluated.
code:
  int print_empty_line()
{
printf("\n");
return 1;
}

void foo(int x)
{
if (x + print_empty_line() < 2 + print_empty_line())
...
}

Quote:
quote:
Optimizer should meet all criteria defined in the language standard concerning the produced binary code, so the only case when it is allowed to alter the results is when the programmer is using constructs which behaviour is undefined by the standard. And the programmer should not be using such constructs.
1) The compiler does comply with the standard.

Which case you considering? Concerning evaluation order it's standard-compliant, but if it replaces 2 calls with one, it's not.
Reply With Quote