8000 [clang] Deduction guides in anonymous namespaces or nested classes trigger -Wunused-function · Issue #141281 · llvm/llvm-project · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[clang] Deduction guides in anonymous namespaces or nested classes trigger -Wunused-function #141281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
armandomontanez opened this issue May 23, 2025 · 3 c 8000 omments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@armandomontanez
Copy link

Summary: Unused deduction guides in anonymous namespaces or for nested classes trigger -Wunused-function.

Example error message:

<source>:12:3: error: unused function '<deduction guide for Bar>' [-Werror,-Wunused-function]
   12 |   Bar() -> Bar<0>;
      |   ^~~

Reproducer: https://godbolt.org/z/zW1KWdK84

This is basically the same failure mode as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106604.

Appears to occur on all existing releases of clang.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label May 23, 2025
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang Clang issues not falling into any other category labels May 24, 2025
@llvmbot
Copy link
Member
llvmbot commented May 24, 2025

@llvm/issue-subscribers-clang-frontend

Author: None (armandomontanez)

Summary: Unused deduction guides in anonymous namespaces or for nested classes trigger `-Wunused-function`.

Example error message:

&lt;source&gt;:12:3: error: unused function '&lt;deduction guide for Bar&gt;' [-Werror,-Wunused-function]
   12 |   Bar() -&gt; Bar&lt;0&gt;;
      |   ^~~

Reproducer: https://godbolt.org/z/zW1KWdK84

This is basically the same failure mode as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106604.

Appears to occur on all existing releases of clang.

@cor3ntin
Copy link
Contributor

@hokein

Sorry, something went wrong.

@zygoloid
Copy link
Collaborator

It seems to me that there are two problems here:

  • We shouldn't be warning for Foo::Bar at all -- the type has external linkage and is accessible in other files, so we shouldn't be warning just because the deduction guide is unused in the current file.
  • The warning for Qux has surprising text and a surprising warning group. A separate warning that talks about deduction guides explicitly, with its own warning group under -Wunused, would make more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

5 participants
0