https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81182
Bug ID: 81182 Summary: result of ‘operator->()’ yields non-pointer result Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at baszerr dot eu Target Milestone: --- Created attachment 41615 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41615&action=edit minimal (not) working example it looks like arrow operator does not work correctly, when it is part of a template class, called from a template function, and return type is "auto". it does not compile, while the code is fine. it also works fine on Clang. $ g++ -Wall arrow_operator.cpp arrow_operator.cpp: In function ‘void problem()’: arrow_operator.cpp:24:7: error: result of ‘operator->()’ yields non-pointer result op->doNothing(); test code reproducing a bug (attached) provides two macros, that define a workaround for the issue: return "auto*" or make calling function ("problem()") not a template. i've also noticed, that defining a non-template function, with the same content as "templated" one, but under a different name, does make the problem disappear as well... but only if the function is before the template - not when it is after.