[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 25 12:07:40 PDT 2025


alexfh wrote:

We've found another issue caused by this patch. I'm not quite sure what the standard says about this, but Clang after this commit is the only recent mainstream compiler that rejects this code (https://gcc.godbolt.org/z/KW56orYca):
```
struct basic_ostream {
  basic_ostream(int);
};
namespace n {
template <class R_> struct Point_2 : R_::Kernel_base::Point_2 {};
template <class R> void insert(basic_ostream, Point_2<R>, int);
struct S1 {};
struct S2 {};
} // namespace n
struct P {};
template <class>
void insert(n::S1 s1, n::S2 s2, int) {
  insert<P>(s1, s2, 0);
}
```

```
<source>:5:42: error: no member named 'Kernel_base' in 'P'
    5 | template <class R_> struct Point_2 : R_::Kernel_base::Point_2 {};
      |                                      ~~~~^
<source>:13:17: note: in instantiation of template class 'n::Point_2<P>' requested here
   13 |   insert<P>(s1, s2, 0);
      |                 ^
<source>:13:3: note: while substituting deduced template arguments into function template 'insert' [with R = P]
   13 |   insert<P>(s1, s2, 0);
      |   ^
1 error generated.
```

The test case above is reduced from https://github.com/CGAL/cgal/blob/5add7e715031a190a87cf6cdc9ad324543a1621a/Triangulation_3/test/Triangulation_3/test_regular_remove_3.cpp, where the error looks like this:
```
cgal/Kernel_23/include/CGAL/Point_2.h:32:28: error: no member named 'Kernel_base' in 'point_iterator_0'
   32 | class Point_2 : public R_::Kernel_base::Point_2
      |                        ~~~~^
cgal/Triangulation_3/test/Triangulation_3/test_regular_remove_3.cpp:350:34: note: in instantiation of template class 'CGAL::Point_2<point_iterator_0>' requested here
  350 |     insert<point_iterator_0> (T, points, 10);
      |                                  ^
cgal/Triangulation_3/test/Triangulation_3/test_regular_remove_3.cpp:350:5: note: while substituting deduced template arguments into function template 'insert' [with R = point_iterator_0]
  350 |     insert<point_iterator_0> (T, points, 10);
      |     ^
```

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


More information about the cfe-commits mailing list