[clang] [clang] disallow narrowing when matching template template parameters (PR #124313)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 25 08:07:03 PST 2025
================
@@ -66,8 +66,9 @@ namespace DependentType {
using ok = Pt<tT0<int, i>, tT0<int, iDi>>;
using err1 = tT0<int, ii>; // expected-error {{too few template arguments for class template 'ii'}}
// expected-note at -1 {{different template parameters}}
- using err2 = tT0<short, i>; // FIXME: should this be OK?
- using err2a = tT0<long long, i>; // FIXME: should this be OK (if long long is larger than int)?
+ using err2 = tT0<short, i>;
+ using err2a = tT0<long long, i>; // expected-error@#tT0 {{cannot be narrowed from type 'long long' to 'int'}}
+ // expected-note at -1 {{different template parameters}}
----------------
mizvekov wrote:
We never allowed non-exact match for floats, so this would be a different problem. It would certainly be the design intention of P0522 to accept non-narrowing non-exact matches there.
Apparently only MSVC accepts non-exact matches here, so this would need some research and maybe a paper.
For enums sure, that works the same as integrals, I'll add a test case.
https://github.com/llvm/llvm-project/pull/124313
More information about the cfe-commits
mailing list