Make using compiled libs with debug code better

Paul Backus snarwin at
Tue Oct 19 14:28:47 UTC 2021

On Tuesday, 19 October 2021 at 13:57:31 UTC, Steven Schveighoffer 
>> Better to leave assertions on by default, and make you have to 
>> go out of your way to turn them off.  IMO.
> This would leave Phobos in pretty bad shape for performance. 
> Especially with invariants. I know for instance that 
> RedBlackTree has an invariant that validates the tree 
> correctness on every operation (and this runs before and after 
> every function). However, if you build your project with dub, 
> every library you depend on (with source available) will be 
> built the same as your application. So Phobos is kind of alone 
> in this regard based on the way we distribute libraries.
> I'm not sure what the right answer is, but that is what this 
> thread is for -- can we solve this in a non-disruptive or 
> minimally-disruptive way?

1. Add a `-preview=releaseModeChecks` switch that enables 
assertions and contract checks in `-release` builds.
2. Build Phobos's unit tests with and without the new `-preview` 
switch and check for performance regressions.
3. Add `debug` to any assertions or contracts that cause 
significant performance regressions.

More information about the Digitalmars-d mailing list