Date: Thu, 23 Oct 2025 15:19:02 -0700
> On Oct 23, 2025, at 3:09 PM, Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>
> On Fri, 24 Oct 2025 at 01:05, Oliver Hunt via Ext <ext_at_[hidden]> wrote:
>> Is the issue that in observe mode in this case that these contract assertions turn into something like (pseudo code)
>>
>> if (p != nullptr) report();
>> if (!p->foo()) report();
>>
>> And the compiler is permitted to assume that `p->foo()` means that `p` is nonnull and back propagate that assumption forward or backwards through time?
>>
>> I had thought that the observable checkpoints were intended to act as a fence that prevented such optimization?
>
> The issue isn't such an optimization, but that the second check has
> UB. It won't propagate backwards, but it's still UB.
Ah, so the scenario is that the only dereference of `p` occurs specifically inside that contract assertion?
If so, that makes more sense, thanks :D
—Oliver
>
> On Fri, 24 Oct 2025 at 01:05, Oliver Hunt via Ext <ext_at_[hidden]> wrote:
>> Is the issue that in observe mode in this case that these contract assertions turn into something like (pseudo code)
>>
>> if (p != nullptr) report();
>> if (!p->foo()) report();
>>
>> And the compiler is permitted to assume that `p->foo()` means that `p` is nonnull and back propagate that assumption forward or backwards through time?
>>
>> I had thought that the observable checkpoints were intended to act as a fence that prevented such optimization?
>
> The issue isn't such an optimization, but that the second check has
> UB. It won't propagate backwards, but it's still UB.
Ah, so the scenario is that the only dereference of `p` occurs specifically inside that contract assertion?
If so, that makes more sense, thanks :D
—Oliver
Received on 2025-10-23 22:19:15
