C++ Logo

std-proposals

Advanced search

Re: [std-proposals] unimplemented attribute

From: Hans Åberg <haberg_1_at_[hidden]>
Date: Thu, 20 Mar 2025 15:50:24 +0100
> On 20 Mar 2025, at 15:09, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> ---------- Forwarded message ---------
> From: Jason McKesson <jmckesson_at_[hidden]>
> Date: Thu, Mar 20, 2025 at 10:07 AM
> Subject: Re: [std-proposals] unimplemented attribute
> To: Hans Åberg <haberg_1_at_[hidden]>
>
> On Thu, Mar 20, 2025 at 5:46 AM Hans Åberg <haberg_1_at_[hidden]> wrote:
>>> On 19 Mar 2025, at 18:52, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> There are two parts, issue a compiler warning and the ability to write an override. Compiler writers may choose to say nothing, like GCC, or adding “delete”, like Clang:
>>
>> In the first case, one gets a compiler error that may hard to read if there is no declaration. In the float128_t example I gave, there will be for functions using it a long list of functions with other argument types, but no mentioning of the function one wants to use.
>>
>> If one adds a declaration there will be a linker error that may be hard to interpret.
>>
>> In these cases, one can write an override.
>>
>> Clang though chooses in some cases to use “delete”, and then one gets a compiler error which cannot be overridden.
>
> You're explaining what behavior you want out of the build system. But
> I'm asking what it *means* to a user. How I as a user should interpret
> such a declaration.
>
> If I see a function declaration, what that means is I expect to be
> able to call that function with those parameters (unless it is
> `delete`d). If I see an `[[unimplemented]]` declaration... can I call
> it or not? If I'm not supposed to call it, then why is it there at
> all? And if I am supposed to call it, why is the attribute there?

It means that it is not implemented but is called for by a specification such as the C++ standard.

If you call such a function, you get a compiler diagnostic saying that it is not implemented. That is the first part.

The second part is the ability to implement it on your own. This part is tricky, and it is unclear if it can be admitted.

>> The underlying semantic meaning is clear, to mark “unimplemented” on features not implemented, say on language features, and may suggest an effect, if giving any. But one may of course decide to choose something else in a compilation.
>
> But if it's not implemented... *why is it there?*

In the example I gave, various functions having float128_t as arguments and return value. Specifically,
  std::float128_t modf(std::float128_t x, std::float128_t* y)
is in the standard, and if one has the type std::float128_t and calls it as expected, one gets a long list of all other type variations of “modf” but this one is not mentioned.

If a declaration is present and marked “unimplemented”, one gets a diagnostic just mentioning this function and that it is not implemented.

> Can I call the
> function or not? That's the question.

You cannot use it unless it is implemented. The intent is to help detecting exactly what is wrong, and if possible, make a workaround.

Received on 2025-03-20 14:50:39