llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.72k stars 11.88k forks source link

Clang type substitution for concepts is too eager #61811

Open cjdb opened 1 year ago

cjdb commented 1 year ago

GCC test concepts4.C fails when it should pass. Apparently this part of temp.constr points out that the type substitution happens later than when we're applying it (cc @zygoloid in case I botched the explanation).

template <class T> struct A { static const int x = 42; };

template <class Ta> concept A42 = A<Ta>::x == 42;
template <class Tv> concept Void = __is_same_as(Tv, void);
template <class Tb, class Ub> concept A42b = Void<Tb> || A42<Ub>;
template <class Tc> concept R42c = A42b<Tc, Tc&>;

static_assert (R42c<void>);
llvmbot commented 1 year ago

@llvm/issue-subscribers-c-20

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend

zygoloid commented 1 year ago

Fixing this will require that we don't compute potentially-unused template arguments during satisfaction checking until they're needed by an atomic constraint. That in turn will get in the way of caching satisfaction results for concepts. We should get performance data for that change and give feedback to WG21 if it looks like this is going to have a significant performance impact.

cjdb commented 1 year ago

I think this is another case: https://godbolt.org/z/E7Kzs5db6 (GCC test concepts-template-parm11.C)