How can we allow using phobos with asserts/contracts?

user1234 user1234 at 12.de
Mon Oct 18 12:35:04 UTC 2021


On Sunday, 17 October 2021 at 21:00:19 UTC, Steven Schveighoffer 
wrote:
> 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

contracts ?

bound checks should be in the body and conditionally compiled 
with `version(D_NoBoundsChecks){} else {}`

then same problem because it's not a function template I guess.
someone should make it a function template then.


More information about the Digitalmars-d-learn mailing list