Issue 184562
Summary [Regression][Concepts] Clang 22 regression: concept default NTTP (g = a::e<f>::h) appears to be reused across instantiations, breaking || short-circuit in constraint checking
Labels clang
Assignees
Reporter craffael
    Reproducer obtained with CReduce (C++20, no headers):

```
  namespace a {
  template <typename b> struct c { using d = b; };
  template <typename b> using e = c<b>::d;
  } // namespace a

  template <class f, char g = a::e<f>::h>
  concept i = g < 3 || requires { typename f::template j<3>; };

  struct k { static constexpr char h = 2; };

  struct l {
    static constexpr char h = 3;
    template <char> using j = k;
  };

  template <i f> struct m {
    using n = m<typename f::template j<1>>;
  };

  m<l> n;
```

## How to build
- Fails: clang++-22 -std=c++20 -c repro.cpp
- Works: clang++-21 -std=c++20 -c repro.cpp
- Works: g++-15 -std=c++20 -c repro.cpp

## Actual behavior (clang++-22)
```
<source>:17:13: error: constraints not satisfied for class template 'm' [with f = typename l::template j<1>]
   17 |   using n = m<typename f::template j<1>>;
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:19:6: note: in instantiation of template class 'm<l>' requested here
   19 | m<l> n;
      |      ^
<source>:16:11: note: because 'typename l::template j<1>' (aka 'k') does not satisfy 'i'
   16 | template <i f> struct m {
      |           ^
<source>:8:13: note: because ''\x03' < 3' (3 < 3) evaluated to false
    8 | concept i = g < 3 || requires { typename f::template j<3>; };
      |             ^
<source>:8:54: note: and 'typename f::template j<3>' would be invalid: no member named 'j' in 'k'
    8 | concept i = g < 3 || requires { typename f::template j<3>; };
      |                                                      ^
```

## Expected behavior
  This should compile. 

##  Notes / workaround

  - Replacing the default with char g = f::h makes clang++-22 accept the code, so the issue seems tied to the alias chain a::e<f> = c<f>::d in the default NTTP.
  - static_assert(i<k>); by itself passes on clang++-22; the failure only appears in the nested constrained instantiation (m<l> → m<k>).

##  Versions

  - Failing: Ubuntu clang version 22.1.1 (Target: x86_64-pc-linux-gnu)
  - Working: Ubuntu clang version 21.1.8; g++-15 (GCC) 15.2.1
  - OS: Ubuntu 24.04.2 LTS

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to