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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
   Last reconfirmed|2012-08-24 00:00:00         |2018-9-20
                 CC|                            |manu at gcc dot gnu.org
            Summary|bug when use named          |valid code rejected (named
                   |operators                   |operator)

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
GCC 9 says:

<source>: In member function 'FOO2<T>::operator FOO2<T>::type() const':
<source>:10:48: error: 'struct FOO' has no member named 'operator
FOO2<T>::type'
10 |     operator type() const { return t->operator type(); }
   |                                                ^~~~

Clang compiles it.

Testcase:

struct FOO
{
    operator int() const { return static_cast< int >(7); }
    operator double() const { return static_cast< double >(7); } };

template < typename T >
struct FOO2
{
    typedef T type;
    operator type() const { return t->operator type(); }
private:
    FOO* t;
};

int main()
{
    FOO2< int > foo2; foo2.operator int();
    return 1;
}

Reply via email to