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

            Bug ID: 96215
           Summary: Wrong mangling for non-dependent return type involving
                    decltype(g.x) or decltype(p->x)
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/z4rjjq

    struct S { int x; int operator*() const; };
    extern const S g;
    extern const S *p;
    extern int S::*m;

    template<class T>
    decltype(g.x) foo() { return 0; }

    template<class T>
    decltype(p->x) bar() { return 0; }

    template int foo<int>();
    template int bar<int>();

Clang mangles these instantiations as
_Z3fooIiEiv
_Z3barIiEiv
GCC mangles them as
_Z3fooIiEDtdtL_Z1gE1xEv
_Z3barIiEDtptL_Z1pE1xEv

Weirdly, GCC doesn't seem to have this issue with any other operators --
decltype(g+1), decltype(g.*m), etc. are all handled as synonyms for `int`. Only
dot and arrow are handled as-if-they-were-dependent-even-though-they-aren't.

Reply via email to