Skip to content

Clang 20 regression: conflicting deduction 'type-parameter-0-0' against 'long' for parameter #138078

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

Closed
jeremy-rifkin opened this issue May 1, 2025 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate

Comments

@jeremy-rifkin
Copy link

#include <type_traits>

template <typename Integer, Integer C, unsigned I, template <typename, Integer, unsigned> class Trait, typename = void>
class Foo : public std::integral_constant<bool, true> {};

template <typename Integer, Integer C, unsigned I>
class Bar : public std::integral_constant<bool, Foo<Integer, C, I, Bar>::value> {};

template <typename Integer, Integer C>
class Bar<Integer, C, 0> : public std::false_type {};

template <typename Integer, unsigned I>
class Baz : public std::integral_constant<bool, Bar<Integer, 1, I>::value> {};

Baz<long, 20> x;

This ostensibly valid code compiles fine on gcc, msvc, and clang 19 but fails on clang 20 with the following error:

<source>:6:20: error: conflicting deduction 'type-parameter-0-0' against 'long' for parameter
    6 | template <typename Integer, Integer C, unsigned I>
      |                    ^
<source>:7:68: note: template template argument has different template parameters than its corresponding template template parameter
    7 | class Bar : public std::integral_constant<bool, Foo<Integer, C, I, Bar>::value> {};
      |                                                                    ^
<source>:3:97: note: previous template template parameter is here
    3 | template <typename Integer, Integer C, unsigned I, template <typename, Integer, unsigned> class Trait, typename = void>
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^
<source>:13:49: note: in instantiation of template class 'Bar<long, 1, 20>' requested here
   13 | class Baz : public std::integral_constant<bool, Bar<Integer, 1, I>::value> {};
      |                                                 ^
<source>:15:15: note: in instantiation of template class 'Baz<long, 20>' requested here
   15 | Baz<long, 20> x;
      |               ^

https://godbolt.org/z/vjYsWPq3q

@llvmbot llvmbot added the clang Clang issues not falling into any other category label May 1, 2025
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang Clang issues not falling into any other category labels May 1, 2025
@llvmbot
Copy link
Member

llvmbot commented May 1, 2025

@llvm/issue-subscribers-clang-frontend

Author: Jeremy Rifkin (jeremy-rifkin)

```cpp #include <type_traits>

template <typename Integer, Integer C, unsigned I, template <typename, Integer, unsigned> class Trait, typename = void>
class Foo : public std::integral_constant<bool, true> {};

template <typename Integer, Integer C, unsigned I>
class Bar : public std::integral_constant<bool, Foo<Integer, C, I, Bar>::value> {};

template <typename Integer, Integer C>
class Bar<Integer, C, 0> : public std::false_type {};

template <typename Integer, unsigned I>
class Baz : public std::integral_constant<bool, Bar<Integer, 1, I>::value> {};

Baz<long, 20> x;


This ostensibly valid code compiles fine on gcc, msvc, and clang 19 but fails on clang 20 with the following error:

```cpp
&lt;source&gt;:6:20: error: conflicting deduction 'type-parameter-0-0' against 'long' for parameter
    6 | template &lt;typename Integer, Integer C, unsigned I&gt;
      |                    ^
&lt;source&gt;:7:68: note: template template argument has different template parameters than its corresponding template template parameter
    7 | class Bar : public std::integral_constant&lt;bool, Foo&lt;Integer, C, I, Bar&gt;::value&gt; {};
      |                                                                    ^
&lt;source&gt;:3:97: note: previous template template parameter is here
    3 | template &lt;typename Integer, Integer C, unsigned I, template &lt;typename, Integer, unsigned&gt; class Trait, typename = void&gt;
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^
&lt;source&gt;:13:49: note: in instantiation of template class 'Bar&lt;long, 1, 20&gt;' requested here
   13 | class Baz : public std::integral_constant&lt;bool, Bar&lt;Integer, 1, I&gt;::value&gt; {};
      |                                                 ^
&lt;source&gt;:15:15: note: in instantiation of template class 'Baz&lt;long, 20&gt;' requested here
   15 | Baz&lt;long, 20&gt; x;
      |               ^

https://godbolt.org/z/vjYsWPq3q

@cor3ntin
Copy link
Contributor

cor3ntin commented May 1, 2025

@mizvekov

@mizvekov
Copy link
Contributor

mizvekov commented May 9, 2025

This is equivalent to / duplicate of #130778

Same explanations there apply. To make this code compatible with all compilers, make this change to the definition of Foo:
https://godbolt.org/z/Yfs8oje7M

template <typename Integer, Integer C, unsigned I, template <typename T, T, unsigned> class Trait, typename = void>
class Foo : public std::integral_constant<bool, true> {};

@mizvekov mizvekov closed this as completed May 9, 2025
@EugeneZelenko EugeneZelenko closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2025
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

5 participants