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

            Bug ID: 90495
           Summary: Incorrect parsing of a<x>()->b<x> construction
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Code:

struct T {
    template <int x>
    int get(int v){return v;}

    template <int x>
    T* getT(){return this;}

    template <int x>
    int get2(){return getT<x>()->get<x>(5);}
};

int main() {
    return T().get2<3>();
}

fails to compile with message

<source>: In instantiation of 'int T::get2() [with int x = 3]':
<source>:13:24:   required from here
<source>:9:37: error: invalid operands of types '<unresolved overloaded
function type>' and 'int' to binary 'operator<'
    9 |     int get2(){return getT<x>()->get<x>(5);}

starting from gcc-7.1 (x86-64) till now including trunk, modules and contracts
branches
compiles on gcc-6.3

Tested locally and on https://godbolt.org/z/IaTDBm

workarounds easily like this

    int get2(){return getT<x>()->template get<x>(5);}

or by splitting calls into several codelines, so it actually does not affect me

Reply via email to