How can we allow using phobos with asserts/contracts?

Steven Schveighoffer schveiguy at gmail.com
Sun Oct 17 21:00:19 UTC 2021


On 10/16/21 6:47 PM, solidstate1991 wrote:
> When I make this call
> ```
> format(" %3.3f"w, avgFPS);
> ```
> my program immediately crashes with an access violation error. The 
> debugger out is different between x86 and x86-64.
> 
> I've made all sanity checks, so I need some other suggestions.

FYI, solidstate figured this out. It was because of an out-of-bounds 
index on `BitArray`.

But that irks me. Why wouldn't `BitArray` do a bounds check? And then I 
remembered -- Phobos is built in release mode even when your app is not.

I literally *cannot* request from the compiler that `BitArray` enforce 
its contracts without rebuilding the library completely. I never want to 
build code that doesn't have bounds checks.

How can we fix this?

-Steve


More information about the Digitalmars-d-learn mailing list