Skip to content

various warnings incorrectly included in -Wc++20-compat #138775

@zygoloid

Description

@zygoloid

Example:

template<typename T> consteval T::type f();

... compiled with -std=c++20 -Weverything produces:

<source>:1:32: warning: use of implicit 'typename' is incompatible with C++ standards before C++20 [-Wc++20-compat]
    1 | template<typename T> consteval T::type f();
      |                                ^
<source>:1:22: warning: 'consteval' specifier is incompatible with C++ standards before C++20 [-Wc++20-compat]
    1 | template<typename T> consteval T::type f();
      |                      ^

This doesn't make sense: -Wc++XY-compat is supposed to warn about compatibility issues that would arise when compiling with -std=c++XY. But that's not what these warnings are about at all!

These warnings should be in -Wpre-c++20-compat, because they warn about compatibility issues that would arise when compiling with standards earlier than -std=c++20. It'd be good to do a survey of other -Wc++XY-compat warnings too, to check for other places we might have got this wrong.

Metadata

Metadata

Assignees

Labels

clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second party

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions