https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104798

--- Comment #2 from Jonathan Stein <jstein27 at binghamton dot edu> ---
Further, after some back and forth with a colleague, I don't know if this is an
extension or not. I'm not too clear on the language, but from the C++20
published draft n4849:

> An attribute-specifier-seq in a lambda-declarator appertains to the **type 
> of** the corresponding
function call operator or **operator template**.

Emphasis mine. A decl-specifier-seq is also allowed, which can have it's own
attribute-specifier-seq which apertains to the type of item that the
decl-specifiers were for. But the decl specifiers for a lambda expression are
only allowed to contain mutable, constexpr, or consteval. The latter two would
be for the operator, but I believe mutable would be for anonymous class.

Is the type of a function call operator the same as the operator? I assume so,
because as far as I'm aware templates ( don't have a type. Which would then
mean, if there's "decl-specifier-seq [[...]] noexcept-spec [[...]]"
(noexcept-spec is optional), the first attribute-specifier-seq _may_ pertain to
the anonymous class (because what does it mean *exactly* to be mutable here
other than for the class), the second to the call operator. If there's only an
attribute-specifier-seq, it's to the call operator. Which means both the lack
of warning and the change in behavior are wrong.

On the other hand, if not, then it applies to the type of the function yet not
the function itself. Which means there's no way to provide function-related
attributes to lambdas pre C++2b except by extension, and the change in behavior
is correct but the lack of warning is not.

Reply via email to