assertNotThrown (and asserts in general)

Malte no at valid.mail
Mon May 21 12:44:21 UTC 2018

I was interested by asserts and how the compiler uses them to 
optimize the code. So I looked at the compiler explorer to see 
how and found it, it doesn't.

What I tried to do is turn a!ulong(byte) to a simple 
cast with the help of assertions.

If there is an assert right before an if with the same condition, 
I think it should remove the compare and jump in release, but it 
doesn't. I'm assuming the compilers just aren't ready yet, but 
should be someday. At least that is what the documentation 

More curious made me 
"assertNotThrown!ConvOverflowException(!ubyte)" where it 
didn't even remove the assert code in release and produced the 
most inefficient assembly.
Is that intended behaviour? In my opinion that greatly limits the 
usabilty of it.

More information about the Digitalmars-d-learn mailing list