[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 14:39:25 PDT 2024


mizvekov wrote:

@alexfh Your third test case reduces to:

```C++
template <unsigned> struct InlinedVector {};

template <int TotalNumArgs>
void PackArgsHelper(InlinedVector<TotalNumArgs>, unsigned char);

template <int TotalNumArgs, typename T0, typename... TRest>
void PackArgsHelper(InlinedVector<TotalNumArgs> packed_args, T0,
                    TRest... args_rest) {
  PackArgsHelper<TotalNumArgs>(packed_args, args_rest...);
}

template void PackArgsHelper<2>(InlinedVector<2>, int, unsigned char);
```

The problem here is the mismatch between `int` and `unsigned int` for TotalNumArgs.

If you replace `template <unsigned> struct InlinedVector {};` with `template <int> struct InlinedVector {};` that works.
Or you can replace the other way around.

Does that solution translate to the unreduced problem? Does that come from Eigen, or is that internal to google?

It's a shame that we produce these diagnostics internally, but we don't have them wired to show up when these happen in partial ordering.

https://github.com/llvm/llvm-project/pull/100692


More information about the cfe-commits mailing list