Date: Mon, 20 Oct 2025 16:16:27 +0100
Hi John,
Contracts add the new issue that you can do everything right and still get
> surprising behavior
If you've done everything right then contracts are completely redundant in
your program.
O.
On Mon, 20 Oct 2025 at 16:14, John Spicer <jhspicer_at_[hidden]> wrote:
> In general, if you do things correctly, you don’t need to understand ODR
> violations.
>
> If you do things incorrectly, it might be hard to figure out. But having
> header files mean different things in difference places is a long-standing
> issue that goes back to C and has always been hard to figure out.
>
> Contracts add the new issue that you can do everything right and still get
> surprising behavior and it is even harder to figure out because your tools
> won’t help you.
>
> John.
>
> On Oct 20, 2025, at 9:56 AM, Oliver Rosten <oliver.rosten_at_[hidden]>
> wrote:
>
> PS Most people I teach have no prior idea what an ODR violation is.
>
> On Mon, 20 Oct 2025 at 14:55, Oliver Rosten <oliver.rosten_at_[hidden]>
> wrote:
>
>> That's a proof of existence but not of wide-spread usage.
>>
>> I am honestly ignorant here. As far as I know the C++ ecosystem as a
>> whole is not making rigorous use of things like this. But I may be wrong...
>>
>> On Mon, 20 Oct 2025 at 14:53, Ville Voutilainen <
>> ville.voutilainen_at_[hidden]> wrote:
>>
>>> On Mon, 20 Oct 2025 at 16:46, Oliver Rosten
>>> <oliver.rosten_at_[hidden]> wrote:
>>> >
>>> > Hi John,
>>> >
>>> > I'm not convinced by this:
>>> >
>>> >> No, it is not a pre-existing problem.
>>> >> Other than contracts, if you end up with different function
>>> definitions it is an ODR violation and your program is IFNDR and can be
>>> rejected by your tools.
>>> >
>>> >
>>> > There's a difference between "can be in principle" and "is in general
>>> practice". Is it not the case that, in most instances, for all practical
>>> purposes there is no difference between an ODR violation that's IFNDR and
>>> the contracts mixed-mode: you get what the linker gives you?
>>>
>>> See, for example,
>>> https://devblogs.microsoft.com/oldnewthing/20160803-00/?p=94015
>>> See also https://maskray.me/blog/2022-11-13-odr-violation-detection
>>>
>>
>
Contracts add the new issue that you can do everything right and still get
> surprising behavior
If you've done everything right then contracts are completely redundant in
your program.
O.
On Mon, 20 Oct 2025 at 16:14, John Spicer <jhspicer_at_[hidden]> wrote:
> In general, if you do things correctly, you don’t need to understand ODR
> violations.
>
> If you do things incorrectly, it might be hard to figure out. But having
> header files mean different things in difference places is a long-standing
> issue that goes back to C and has always been hard to figure out.
>
> Contracts add the new issue that you can do everything right and still get
> surprising behavior and it is even harder to figure out because your tools
> won’t help you.
>
> John.
>
> On Oct 20, 2025, at 9:56 AM, Oliver Rosten <oliver.rosten_at_[hidden]>
> wrote:
>
> PS Most people I teach have no prior idea what an ODR violation is.
>
> On Mon, 20 Oct 2025 at 14:55, Oliver Rosten <oliver.rosten_at_[hidden]>
> wrote:
>
>> That's a proof of existence but not of wide-spread usage.
>>
>> I am honestly ignorant here. As far as I know the C++ ecosystem as a
>> whole is not making rigorous use of things like this. But I may be wrong...
>>
>> On Mon, 20 Oct 2025 at 14:53, Ville Voutilainen <
>> ville.voutilainen_at_[hidden]> wrote:
>>
>>> On Mon, 20 Oct 2025 at 16:46, Oliver Rosten
>>> <oliver.rosten_at_[hidden]> wrote:
>>> >
>>> > Hi John,
>>> >
>>> > I'm not convinced by this:
>>> >
>>> >> No, it is not a pre-existing problem.
>>> >> Other than contracts, if you end up with different function
>>> definitions it is an ODR violation and your program is IFNDR and can be
>>> rejected by your tools.
>>> >
>>> >
>>> > There's a difference between "can be in principle" and "is in general
>>> practice". Is it not the case that, in most instances, for all practical
>>> purposes there is no difference between an ODR violation that's IFNDR and
>>> the contracts mixed-mode: you get what the linker gives you?
>>>
>>> See, for example,
>>> https://devblogs.microsoft.com/oldnewthing/20160803-00/?p=94015
>>> See also https://maskray.me/blog/2022-11-13-odr-violation-detection
>>>
>>
>
Received on 2025-10-20 15:16:42
