C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[unevaluated]]

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Wed, 20 May 2026 07:44:47 +0100
On Wed, 20 May 2026, 07:15 Frederick Virchanza Gotham via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

>
>
> On Tuesday, May 19, 2026, Jonathan Wakely wrote:
>>
>>
>>
>>
>>> But I think we'd be better off with an attribute that tells the compiler
>>> exactly what we have in mind. And of course the attribute would ensure that
>>> the function is not emitted in the object file.
>>>
>>
>> You get that with consteval.
>>
>
>
>
> Inside the body of a consteval function, if you make a call to a
> non-constexpr function, you get a compiler warning.
>
> Also if you were to invoke 'optional::operator*' before invoking
> 'optional::has_value', you might get a warning (e.g. from cppcheck).
>
> To cut down on warnings, and to ensure that the function actually never
> gets invoked -- not even in a consteval context at compile time -- it would
> be better to tell the compiler (and also tell cppcheck) that the function
> is [[unevaluated]]. And if someone tries to take its address or invoke it,
> I would like this to be an error rather than a warning.
>


You "forgot" to reply to the part where I asked for motivation. No change
there then.

Received on 2026-05-20 06:45:09