[llvm-bugs] [Bug 52524] New: Ambiguous instantiation while asserting requirement is not a hard error

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 16 10:10:46 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=52524

            Bug ID: 52524
           Summary: Ambiguous instantiation while asserting requirement is
                    not a hard error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P
         Component: C++2b
          Assignee: unassignedclangbugs at nondot.org
          Reporter: johelegp at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    johelegp at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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>);
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211116/2714d9be/attachment.html>


More information about the llvm-bugs mailing list