Date: Thu, 26 Mar 2026 21:37:59 -0700
Switching all asserts to assume statements saved ~20% of the "user"
time spent running a test suite of 316 tests. And took 3.5% off the
stripped executable size. These are just test cases for random
"system" code, not a particular benchmark. So I would expect similar
results for any assert heavy code base. I can try instrumenting a
better example if anyone has one in mind.
In my case I have container libraries and algorithms that have every
reasonable assert, something the standard library currently lacks.
Having this would also help with the standard with optimization under
this proposal. https://github.com/whatchamacallem/libhatchet/
Certain extremophiles consider these optimizations important, just to
squeeze a few bytes out of their code size, many would not.
I have been running exhaustive test coverage (e.g. 98% line coverage)
while doing active development for months and I have never seen a
single bug result from converting all asserts to "assume" statements.
I'll admit I was a little surprised it just worked without a hitch.
On Thu, Mar 26, 2026 at 8:12 PM Tony V E <tvaneerd_at_[hidden]> wrote:
>
>
>
> On Thu, Mar 26, 2026 at 5:41 PM Adrian Johnston via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>>
>> I have implemented this kind of [[assume_assert(expr)]] using
>> compiler-specific intrinsics and used it for every last assertion in a
>> non-trivial codebase. It worked great, and so I am recommending it for
>> the next version of C++26.
>>
>
> What does "worked great" mean?
> Did you find bugs?
> Did the code get faster?
> It compiled and seems to work :shrug-emoji: ?
>
>
> --
> Be seeing you,
> Tony
time spent running a test suite of 316 tests. And took 3.5% off the
stripped executable size. These are just test cases for random
"system" code, not a particular benchmark. So I would expect similar
results for any assert heavy code base. I can try instrumenting a
better example if anyone has one in mind.
In my case I have container libraries and algorithms that have every
reasonable assert, something the standard library currently lacks.
Having this would also help with the standard with optimization under
this proposal. https://github.com/whatchamacallem/libhatchet/
Certain extremophiles consider these optimizations important, just to
squeeze a few bytes out of their code size, many would not.
I have been running exhaustive test coverage (e.g. 98% line coverage)
while doing active development for months and I have never seen a
single bug result from converting all asserts to "assume" statements.
I'll admit I was a little surprised it just worked without a hitch.
On Thu, Mar 26, 2026 at 8:12 PM Tony V E <tvaneerd_at_[hidden]> wrote:
>
>
>
> On Thu, Mar 26, 2026 at 5:41 PM Adrian Johnston via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>>
>> I have implemented this kind of [[assume_assert(expr)]] using
>> compiler-specific intrinsics and used it for every last assertion in a
>> non-trivial codebase. It worked great, and so I am recommending it for
>> the next version of C++26.
>>
>
> What does "worked great" mean?
> Did you find bugs?
> Did the code get faster?
> It compiled and seems to work :shrug-emoji: ?
>
>
> --
> Be seeing you,
> Tony
Received on 2026-03-27 04:38:10
