https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78704
Bug ID: 78704 Summary: operator-> pointer return type is not recognized as pointer type Product: gcc Version: 6.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: joseph.h.garvin at gmail dot com Target Milestone: --- My coworker Jay Miller discovered this but he couldn't create an account because of the spam restriction in effect. He tried to send an e-mail to the overseers list as suggested but it bounced back -- it's possible nobody can create accounts or request them right now. In this minimal test case operator-> returns a pointer type but neither GCC 4.9 or 6.2 recognize it as such: struct Object { int key; }; // Making this a class rather than a template allows it to compile template <typename Key> class Foo { public: // Changing the returning type to const Object* allows it to compile auto operator->() const { return &b; } private: Object b; }; // Making this a class rather than a template allows it to compile template <typename T> class X { protected: Foo<int> cont; public: int get_val() const { // error: result of 'operator->()' yields non-pointer result return cont->key; // Calling operator-> directory compiles fine //return cont.operator->()->key; } }; int main() { return 0; }