checkedint call removal
eles via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 31 21:51:05 PDT 2014
On Thursday, 31 July 2014 at 20:57:10 UTC, Andrei Alexandrescu
wrote:
> On 7/31/14, 12:37 PM, Daniel Gibson wrote:
>>
>> 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.
>
> Yah, I think that's a good outcome. We must document assert
> better. -- Andrei
Let me try:
"assert() expresses a contract that must be true at that point
for the program to continue correctly.
Compiler (and the optimizer therein) will generate code that
works as intended as long as these contracts are true.
While in Debug mode code for checking the validity of contracts
is actually generated and failure of contracts will result in
halting the program, in Release mode the code is no longer
(guaranteed to be) generated and this results in undefined
behavior.
assert(0) is a special contract that requires no code for its
verification, as it obviously fails. This is why the compiler
will always make it a halting point, in all builds."
More information about the Digitalmars-d
mailing list