[[maybe_unused]] attribute used inside a template argument specifying a type of a function causes a compilation error #108095
Labels
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
confirmed
Verified by a second party
diverges-from:edg
Does the clang frontend diverge from edg compiler
diverges-from:gcc
Does the clang frontend diverge from gcc on this issue
diverges-from:msvc
Does the clang frontend diverge from msvc on this issue
If a specification of a type of a function in a template argument uses the
[[maybe_unused]]
attribute an error is raised - the initial[
is interpreted as a beginning of a lambda capture.This description is quite a mouthful, so let me give an example. The following code:
Causes the following error:
The quoted error is for x86-64 clang 18.1.0 from godbolt, but it is almost identical for all versions (at least) since 12.0.0.
I agree the
[[maybe_unused]]
attribute makes little sense in the presented context. However, at least to my understanding, the mentioned example is valid C++ syntax. I also believe a valid use case where it should be accepted is generated code. This, in fact, is how the issue was identified.Other compilers (GCC and MSVC) correctly compile the code.
The text was updated successfully, but these errors were encountered: