Skip to content
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

-Wunused-const-variable incorrectly warns for exported lambda #85122

Closed
davidstone opened this issue Mar 13, 2024 · 2 comments
Closed

-Wunused-const-variable incorrectly warns for exported lambda #85122

davidstone opened this issue Mar 13, 2024 · 2 comments
Assignees
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:modules C++20 modules and Clang Header Modules false-positive Warning fires when it should not lambda C++11 lambda expressions

Comments

@davidstone
Copy link
Contributor

Compiling the following translation unit with -Wunused-const-variable:

export module a;

export constexpr auto a = []{};

causes clang to report

<source>:3:23: warning: unused variable 'a' [-Wunused-const-variable]
    3 | export constexpr auto a = []{};
      |                       ^
1 warning generated.
Compiler returned: 0

See it live: https://godbolt.org/z/555Y3q9fe

Anything exported from a module should never be considered unused.

@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-positive Warning fires when it should not lambda C++11 lambda expressions and removed new issue labels Mar 13, 2024
@shafik
Copy link
Collaborator

shafik commented Mar 13, 2024

CC @ChuanqiXu9

@ChuanqiXu9 ChuanqiXu9 self-assigned this Mar 14, 2024
@tbaederr tbaederr added the clang:modules C++20 modules and Clang Header Modules label Mar 14, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 14, 2024

@llvm/issue-subscribers-clang-modules

Author: David Stone (davidstone)

Compiling the following translation unit with `-Wunused-const-variable`:
export module a;

export constexpr auto a = []{};

causes clang to report

&lt;source&gt;:3:23: warning: unused variable 'a' [-Wunused-const-variable]
    3 | export constexpr auto a = []{};
      |                       ^
1 warning generated.
Compiler returned: 0

See it live: https://godbolt.org/z/555Y3q9fe

Anything exported from a module should never be considered unused.

tmatheson-arm pushed a commit to tmatheson-arm/llvm-project that referenced this issue Apr 22, 2024
Close llvm#85122

As the title suggested, it looks pretty sensible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang:modules C++20 modules and Clang Header Modules false-positive Warning fires when it should not lambda C++11 lambda expressions
Projects
None yet
Development

No branches or pull requests

6 participants