C++ Logo

sg15

Advanced search

Re: [isocpp-sg15] [isocpp-sg21] [isocpp-admin] Swedish mirror committee consideration on the current working draft

From: Timur Doumler <cpp_at_[hidden]>
Date: Fri, 26 Sep 2025 10:58:43 +0300
...and the reason someone might want such new technology, instead of what you described and what Iain prototyped, is that they might not want to pay any overhead on assertions that end up being ignored (which is quite an important requirement for some people given that C assert does give you that guarantee today).

With the approach you outlined where you bake in a "hook" to delay the choice of semantics until link time / load time / runtime, LTO can eliminate this overhead in some scenarios, but not in the general case where you link against precompiled binaries coming from a 3rd party or you're dealing with a dynamic library.

Cheers,
Timur

> On 26 Sep 2025, at 10:47, Timur Doumler via SG15 <sg15_at_[hidden]> wrote:
>
> Hi Ville,
>
> Oh, I see where the misunderstanding came from. Thanks for explaining.
>
> Yes, what you describe matches closely how Iain described his prototype to me. And yes, this (link-time or runtime selection of semantic where YOU control the compilation) does not require new technology.
>
> What does require new technology is to be able to tell, from an already compiled binary (potentially from a 3rd party) with a fixed semantic baked in at compile time, which semantic was used in that binary, and then do things like Harald suggested (reject the binary if it doesn't have the semantic you want) or more generally, make a deterministic choice between different versions of the same function compiled with different baked-in semantics, at link time.
>
> I am sorry if this distinction wasn't clear. I will make sure to make it very clear in the upcoming paper.
>
> Are we good now?
>
> Timur
>
>> On 26 Sep 2025, at 10:43, Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>>
>> On Fri, 26 Sept 2025 at 10:27, Timur Doumler <cpp_at_[hidden]> wrote:
>>>
>>> Hi Ville,
>>>
>>>> On 26 Sep 2025, at 10:24, Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>>>> Link-time selection of contract evaluation semantics doesn't in and of
>>>> itself require the new technology you seem to be suggesting.
>>>
>>> That's interesting. How would you do it without new technology?
>>
>> You
>> 1) have your compiler compile contract assertions so that the
>> generated code invokes a function to determine the evaluation
>> semantic,
>> and enables/disables a predicate based on that, and decides between
>> enforce/observe based on that
>> 2) link exactly one definition of that function into your program
>> 3) when you link, you can choose which definition to link, out of
>> multiple options. Just link in the object file that gives the desired
>> evaluation semantic.
>>
>> Piece of cake. No funny mangling approaches, new 'technology', or new
>> toolchains necessary.
>>
>> Considering that Iain does actually have a PoC of something like that,
>> it baffles me that there's some "requires new technology to achieve"
>> imaginations. I would be remotely interested where such imaginations
>> come from, because they certainly seem odd and far-fetched to me.
>>
>> Extend the aforementioned function to call a user-installable hook, or
>> consult environment variables, or both, and you have run-time
>> selection
>> of a contract evaluation semantic.
>
> _______________________________________________
> SG15 mailing list
> SG15_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg15

Received on 2025-09-26 07:58:46