Use-after-scope bug in Phobos unittest, how to fix?

Johan j at j.nl
Mon May 15 19:19:20 UTC 2023


On Monday, 15 May 2023 at 18:59:12 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
> You should probably disable such optimizations for @system code 
> entirely. Not sure about @trusted, don't think it should apply 
> there either.
>
> Having optimizations that allow for UB or crashing at runtime 
> is not a good thing.

I think there is a misunderstanding here. The use-after-scope UB 
of the unittest is UB regardless of optimization. Optimization 
(when correct) doesn't change the validity of the program.
If you don't want optimizations uncovering latent UB bugs, then 
you should not use an optimizing compiler. ;)

-Johan



More information about the Digitalmars-d mailing list