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

Spurious -Wpre-c++2b-compat warning with -std=c++2b -pedantic #61582

Closed
timsong-cpp opened this issue Mar 21, 2023 · 3 comments
Closed

Spurious -Wpre-c++2b-compat warning with -std=c++2b -pedantic #61582

timsong-cpp opened this issue Mar 21, 2023 · 3 comments
Labels
c++23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party

Comments

@timsong-cpp
Copy link

struct A {
    void operator[](int, int);
};

with -std=c++2b -pedantic (https://gcc.godbolt.org/z/qnjd5YhPa):

<source>:2:10: warning: overloaded 'operator[]' with more than one parameter is a C++2b extension [-Wpre-c++2b-compat]
    void operator[](int, int);
         ^
1 warning generated.

I would not have expected -pedantic to warn me about constructs that are ill-formed in a previous standard.

@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer c++23 and removed new issue labels Mar 21, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 21, 2023

@llvm/issue-subscribers-c-2b

@timsong-cpp
Copy link
Author

It looks like static lambdas have a similar problem (https://gcc.godbolt.org/z/rWKdWvsv5):

auto x = [] static {};
<source>:1:13: warning: static lambdas are incompatible with C++ standards before C++2b [-Wpre-c++2b-compat]
auto x = [] static {};
            ^

AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Mar 21, 2023
We were accidentally issuing "overloaded 'operator[]' with more than
one parameter is a C++2b extension" with -pedantic because it was an
ExtWarn diagnostic rather than a Warning. This corrects the diagnostic
category and adds some test coverage.

Fixes llvm#61582
@AaronBallman
Copy link
Collaborator

I looked through the rest of the C++2b precompat warnings to see if any more were also mistaken, and it seems like that's the last one. I'll get it fixed up.

AaronBallman added a commit that referenced this issue Mar 21, 2023
We were accidentally issuing "static lambdas are incompatible with C++
standards before C++2b" with -pedantic because it was an ExtWarn
diagnostic rather than a Warning. This corrects the diagnostic category
and adds some test coverage.

Fixes #61582
tru pushed a commit that referenced this issue Mar 23, 2023
We were accidentally issuing "overloaded 'operator[]' with more than
one parameter is a C++2b extension" with -pedantic because it was an
ExtWarn diagnostic rather than a Warning. This corrects the diagnostic
category and adds some test coverage.

Fixes #61582
tru pushed a commit that referenced this issue Mar 24, 2023
We were accidentally issuing "static lambdas are incompatible with C++
standards before C++2b" with -pedantic because it was an ExtWarn
diagnostic rather than a Warning. This corrects the diagnostic category
and adds some test coverage.

Fixes #61582

(cherry picked from commit b904e68)
Noxime pushed a commit to Noxime/llvm-project that referenced this issue Jun 16, 2023
We were accidentally issuing "overloaded 'operator[]' with more than
one parameter is a C++2b extension" with -pedantic because it was an
ExtWarn diagnostic rather than a Warning. This corrects the diagnostic
category and adds some test coverage.

Fixes llvm#61582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

4 participants