Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Ambiguous instantiation while asserting requirement is not a hard error #51491

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52524
Status NEW
Importance P enhancement
Reported by Johel Ernesto Guerrero Peña (johelegp@gmail.com)
Reported on 2021-11-16 10:10:46 -0800
Last modified on 2021-11-16 10:34:02 -0800
Version trunk
Hardware PC Linux
CC blitzrakete@gmail.com, erik.pilkington@gmail.com, johelegp@gmail.com, leni536@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
This came up at https://cpplang.slack.com/archives/C21PKDHSL/p1637078846410400.

From reading https://wg21.link/LWG3541, it seems that the lack of a
disambiguating specialization should result in a hard error, which does not
happen. See https://godbolt.org/z/vMzPnYvr7.

```C++
#include <concepts>
template<class> struct trait { };
template<class T> concept has_type1 = requires { typename T::type1; };
template<class T> concept has_type2 = requires { typename T::type2; };
template<has_type1 T>                       struct trait<T> { using type =
typename T::type1; };
template<has_type2 T>                       struct trait<T> { using type =
typename T::type2; };
template<has_type1 T> requires has_type2<T> and std::same_as<typename T::type1,
typename T::type2>
                      struct trait<T> { using type = typename T::type1; };
template<class T> concept has_trait_type = requires { typename trait<T>::type;
};
struct Y {
  using type1 = double;
  using type2 = int;
};
static_assert(not has_trait_type<Y>);