checkedint call removal

Daniel Gibson via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 12:37:11 PDT 2014


Am 31.07.2014 21:19, schrieb Walter Bright:
> That's the way assert in C/C++ conventionally worked. But this is
> changing. Bearophile's reference made it clear that Microsoft C++ 2013
> has already changed, and I've seen discussions for doing the same with
> gcc and clang.

This will break so much code :-/

>
> In fact, the whole reason assert is a core language feature rather than
> a library notion is I was anticipating making use of assert for
> optimization hints.

So why is this not documented?
The assert documentation isn't even clear on when an AssertError is 
thrown and when execution is halted (http://dlang.org/contracts.html 
doesn't mention halt at all).
And it says "When compiling for release, the assert code is not 
generated." - if you implemented assert like this so the optimizer can 
assume the assertion to be true even when "assert code is not generated" 
this is certainly something developers should be very aware of - and not 
once you actually implement that optimization, but from day one, so they 
can use assert accordingly!

This thread however shows that many D users (who probably have more D 
experience than myself) are not aware that assert() may influence 
optimization and would prefer to have separate syntax to tell the 
optimizer what values he can expect.

Cheers,
Daniel


More information about the Digitalmars-d mailing list