mizvekov wrote:

> The underlying issue is that, whether we want to allow users to instantiate 
> templates from a decltype expression; technically we shouldn't but before our 
> normalization patch it was accidentally allowed (we instantiated the 
> constexpr functions before substituting into decltypes whereas we normalize 
> decltype first and then substitute now) and mpunits seems to rely on that 
> behavior.

But there are some situations where we have to instantiate templates from a 
decltype expression: https://compiler-explorer.com/z/ebc58Yq8z
```C++
template<class T> struct A {
    static_assert(false);
};
using X = decltype(A<int>::m);
```

Or closer to the example here: https://compiler-explorer.com/z/nGxbhM96n
```C++
template<class T> consteval auto f() {
    static_assert(false);
    return 3;
}
using X = decltype(f<int>());
```

Ie with a placeholder return type, you still have to instantiate a consteval 
function in an unevaluated context.

I suspect this patch does not handle a test case such as:
```C++
template<class>
struct reference {};
template<class Q>
consteval auto get_spec(reference<Q>) { return Q{}; }

template<class T>
concept repr_impl = sizeof(T) > 0;
template<class, auto V>
concept representation_of = repr_impl<decltype(V)>;
template<auto V, representation_of<get_spec(V)>>
struct quantity {};

auto x = quantity<reference<int>{}, int>{};
```

Does it?

Ie the above is the same as the test case currently in the PR, but `get_spec` 
now has a placeholder return type.

https://github.com/llvm/llvm-project/pull/196791
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to