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] Poor diagnostic with wrong template argument type #121235

Open
antoniofrighetto opened this issue Dec 27, 2024 · 0 comments
Open

[clang] Poor diagnostic with wrong template argument type #121235

antoniofrighetto opened this issue Dec 27, 2024 · 0 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang Clang issues not falling into any other category enhancement Improving things as opposed to bug fixing, e.g. new or missing feature

Comments

@antoniofrighetto
Copy link
Contributor

Clang diagnostic for invalid bool-to-enum template parameter conversion lacks failure detail when compared to GCC, as the following C++ snippet:

enum endianness { little = 0, big };

template <endianness e>
inline void foo() {}

void bar() {
    foo<false>();
}

Fails as follows on latest clang:

<source>:7:5: error: no matching function for call to 'foo'
    7 |     foo<false>();
      |     ^~~~~~~~~~
<source>:4:13: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'big_endian'
    4 | inline void foo() {}

GCC explicitly indicates the conversion failure instead:

<source>:4:13: note: template argument deduction/substitution failed:
<source>:7:15: error: could not convert 'false' from 'bool' to 'endianness'
    7 |     foo<false>();
      |     ~~~~~~~~~~^~
      |               |
      |               bool

Godbolt: https://godbolt.org/z/hnazTn3M7 (cc/ @shafik).

@antoniofrighetto antoniofrighetto 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 Dec 27, 2024
@tbaederr tbaederr added the enhancement Improving things as opposed to bug fixing, e.g. new or missing feature label Dec 28, 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 clang Clang issues not falling into any other category enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
Development

No branches or pull requests

2 participants