[Bug c++/69701] "v.operator T()" incorrectly parsed if "v.T()" present.

language.lawyer at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 7 19:37:19 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69701

Language Lawyer <language.lawyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |language.lawyer at gmail dot com

--- Comment #7 from Language Lawyer <language.lawyer at gmail dot com> ---
Another example related to CWG2396:

struct B
{
    struct S {};
    operator S();
}; 

auto v = B{}.operator struct S(); // error: 'struct B' has no member named
'operator S'

It can be checked that GCC injects unrelated `struct S` into the global
namespace and then tries to find `operator struct ::S` in B.

However, according to P1787R6 [basic.lookup.unqual]/5: An unqualified name that
is a component name of a type-specifier or ptr-operator of a conversion-type-id
is looked up in the same fashion as the conversion-function-id in which it
appears.

In an elaborated-type-specifier of the form "class-key identifier", such as
`struct S`, identifier is a component name ([dcl.type.elab]/1), so S shall be
searched in B first.


More information about the Gcc-bugs mailing list