https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123350
Bug ID: 123350
Summary: same typedef found in different classes is rejected as
ambiguous
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: brunopitrus at hotmail dot com
Target Milestone: ---
This code (reduced from an example in Chromium codebase is rejected by GCC:
template<class T> concept Concept = requires {typename T::marker;};
struct Base1{
using marker = int;
};
struct Base2{
using marker = int;
};
struct bob: Base1, Base2{};
static_assert(Concept<bob>);
with the following error message:
<source>:11:15: error: static assertion failed
11 | static_assert(Concept<bob>);
| ^~~~~~~~~~~~
• constraints not satisfied
• required by the constraints of 'template<class T> concept Concept'
<source>:1:27:
1 | template<class T> concept Concept = requires {typename
T::marker;};
| ^~~~~~~
• in requirements [with T = bob]
<source>:1:37:
1 | template<class T> concept Concept = requires {typename
T::marker;};
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
• the required type 'typename T::marker' is invalid, because
<source>:1:56:
1 | template<class T> concept Concept = requires {typename
T::marker;};
| ~~~~~~~~~^~~~~~~~~~
• error: lookup of 'marker' in 'bob' is ambiguous
• candidates are: 'using Base2::marker = int'
<source>:6:15:
6 | using marker = int;
| ^~~~~~
• 'using Base1::marker = int'
<source>:3:15:
3 | using marker = int;
| ^~~~~~
Compiler returned: 1
Clang accepts this code. Both GCC and Clang reject this when the definitions of
`marker` are actually conflicting.
See it on godbolt: https://godbolt.org/z/zWcTez8Gs