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

clang-cl.exe: False positive C++17 warning in C++14: out-of-line definition of constexpr static data member #65689

Open
dmitrykobets-msft opened this issue Sep 7, 2023 · 1 comment
Labels
c++14 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@dmitrykobets-msft
Copy link

When compiling with C++14, I'm getting a warning that pertains only to C++17.
I tried this out with LLVM 17.0.0-rc4.

Repro

class A
{
    static constexpr const int i{0};
};
constexpr const int A::i;

int main()
{
}

clang-cl.exe <thefile.cpp> /std:c++14 -Weverything

Output
warning: out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Wdeprecated-redundant-constexpr-static-def]

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

llvmbot commented Sep 7, 2023

@llvm/issue-subscribers-c-14

dmitrykobets-msft added a commit to microsoft/GSL that referenced this issue Sep 11, 2023
Two warnings were being emitted in the MSVC+LLVM tests. 

The warning `-Wunsafe-buffer-usage` is initially introduced in some capacity here https://reviews.llvm.org/D137346 pointing to documentation at https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734. The warning is a stylistic checker whose goal is to "emit a warning every time an unsafe operation is performed on a raw pointer". This type of programming model is not useful for library implementations of types such as `span`, where direct manipulation of raw pointers is inevitable, so disable the warning altogether.

There is also a false-positive warning llvm/llvm-project#65689 that I've disabled inline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++14 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

No branches or pull requests

3 participants