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

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 3 04:48:13 GMT 2021


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So I think clang and MSVC have a bug in this area too.

See basic.lookup.classref/7 :
If the id-expression is a conversion-function-id, its conversion-type-id is
first looked up in the class of the object
expression (11.8) and the name, if found, is used. Otherwise it is looked up in
the context of the entire
postfix-expression. In each of these lookups, only names that denote types or
templates whose specializations
are types are considered. [Example:
struct A { };
namespace N {
struct A {
void g() { }
template <class T> operator T();
};
}
int main() {
N::A a;
a.operator A(); // calls N::A::operator N::A
}
— end example]

If we take the example, clang and MSVC calls N::A::operator ::A and not what
the standard says.

GCC I think is still wrong in the original testcase I think because B::A does
not represent a type .
In my example in comment #4, GCC and ICC does the correct thing and selects the
correct type.


More information about the Gcc-bugs mailing list