assert semantic change proposal

eles via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 6 01:28:07 PDT 2014


On Wednesday, 6 August 2014 at 07:29:02 UTC, Ola Fosheim Grøstad 
wrote:
> On Wednesday, 6 August 2014 at 06:56:40 UTC, eles wrote:

> Not right:
>
> b = a+1
> assume(b>C)
>
> implies
>
> assume(a+1>C)
> b = a+1

b = a+1
if(C<=b) exit(1);

implies

if(C<=a+1) exit(1);
b = a+1

Is not the same? Still, one would allow the optimizer to exit 
before executing b=a+1 line (in the first version) based on that 
condition (considering no volatile variables).

I stick to my point: as long as the code is there, optimization 
based on it is acceptable (as long as the functionality of the 
program is not changed, of course). The sole floating point is 
what to do when the code that is used for optimization is 
discarded.

Would you accept optimization of a C program based on code that 
is guarded by:

#ifndef _NDEBUG
//code that could be used for optimization
#endif

in the -D_NDEBUG version?

(I am not convinced 100% that for D is the same, but should help 
with the concepts)


More information about the Digitalmars-d mailing list