Skip to content

[clang] Diagnose invalid specializations of type traits #101509

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
ldionne opened this issue Aug 1, 2024 · 1 comment
Open

[clang] Diagnose invalid specializations of type traits #101509

ldionne opened this issue Aug 1, 2024 · 1 comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@ldionne
Copy link
Member

ldionne commented Aug 1, 2024

The following code is ill-formed, but we don't diagnose it:

#include <type_traits>

template <>
struct std::common_type<int, int> { using type = long; }; // should warn

struct Foo { };
template <>
struct std::common_type<Foo> { using type = int; }; // should warn

template <>
struct is_integral<Foo> { }; // should warn

// etc...

It would be nice if Clang caught invalid specializations of std::common_type, and in fact perhaps of the other type trait classes as well.

Extracted from #99473 (comment).

@ldionne ldionne added clang Clang issues not falling into any other category clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer labels Aug 1, 2024
@MitalAshok
Copy link
Contributor

Related: #101469 (libc++ can use this for the is_integral case to get the warning)

@EugeneZelenko EugeneZelenko removed the clang Clang issues not falling into any other category label Aug 1, 2024
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
Projects
None yet
Development

No branches or pull requests

3 participants