C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 18 May 2024 15:43:11 -0400
On Sat, May 18, 2024 at 3:04 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> On Saturday, May 18, 2024, Lénárd Szolnoki wrote:
>> This is "possible" in the sense that it's UB, and the UB manifests (possibly) in a function that returns a locked mutex.
>>
>> I know what you are getting at, but it's currently inexpressible in portable standard C++.
>
>
>
> If I get up this coming Monday morning and open up Outlook to check my work email, and see that my boss has emailed me saying "We need to add a new function to the SDK that returns a locked mutex by value", I know I'll be able to provide what he wants, and I know I'll be able to provide it for any platform (MS-Windows, Linux, Arduino, Texas Instruments).
>
> If I'm ever paranoid about the Standard's threat of undefined behaviour, I can always look at the disassembled machine code to make sure it does what I want, and if I'm lazy or in a rush or unfamiliar with the instruction set, then I can ask ChatGPT to explain it to me line by line.
>
> Just making the point here that the word 'possible' exists on a spectrum. If your company has a $13m contract to write an SDK that returns a modified object by value, and you need to provide the solution otherwise your company will go bankrupt and you won't be able to afford your child's insulin, then you *can* do it and it *will* work.

In the context of an actual proposal for standard C++, there is no
"spectrum". There is "allowed by the rules of the standard" or "not
allowed". There may be some fuzzy lines where the language of the
standard is unclear, but this is not one of those cases.

The thing you want to do is "not allowed". Whether you can get away
with it on some implementation is relevant only to the question of
what it might take for future implementations to implement such
functionality should it become "allowed by the rules of the standard".

Received on 2024-05-18 19:43:26