https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127886

            Bug ID: 127886
           Summary: [miscompilation] gcc fails template argument deduction
                    for a template template parameter pack and calls the
                    fallback overload
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 0599jiangyc at gmail dot com
  Target Milestone: ---

The following code:

```cpp
#include <cstdio>
template <int> struct X {};
template <long> struct Y {};
template <class... T> struct A {
  template <template <T> class... TP> struct B {};
  template <template <T> class... TP> static char (&f(B<TP...>*))[10 +
sizeof...(TP)];
  static char (&f(...))[1];
};
int main() {
  A<int>::B<X>* p = 0;
  A<int, long>::B<X, Y>* q = 0;
  std::printf("%d %d %d\n", (int)sizeof(A<int>::f(p)), (int)sizeof(A<int,
long>::f(q)), (int)sizeof(A<int>::f(0)));
  return 0;
}
```

gcc 16.2 result: `1 1 1`, https://godbolt.org/z/eKqEsqz9b

expected result: `11 12 1`, clang reference https://godbolt.org/z/M9Kfn6Ecn

trunk ICE: https://godbolt.org/z/85Poj7vv5

Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120742, original report
is crash-on-invalid

Reply via email to