assert and static assert and code generatio

Rene Zwanenburg renezwanenburg at gmail.com
Thu Jun 15 11:24:09 UTC 2023


On Thursday, 15 June 2023 at 08:55:49 UTC, FeepingCreature wrote:
> I think the idea is more that:
>
> ```
> assert(x < 100);
> ...
> if (x < 200) {
> ```
> And the `if` should be optimized into a constant `if (true)`.
> In other words, if DMD does value range propagation based on 
> asserts.

There were some big wars about this almost a decade ago. It was 
Walter's intention to indeed use asserts for optimization, even 
if the asserts themselves weren't compiled in. IIRC it was 
decided to not do this in the end.

Here's one of the threads about the subject from back then in 
case you have some time to kill:
https://forum.dlang.org/post/lrbpvj$mih$1@digitalmars.com


More information about the Digitalmars-d mailing list