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

            Bug ID: 79304
           Summary: [7 Regression] diagnostic shows bogus expression
                    ((X<T>*)this)->.c
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

struct C { };

template<class T>
struct X
{
  C* c;

  void f() {
    this->c.s();
  }
};

int main()
{
  X<int> x;
  x.f();
}

x.cc: In member function 'void X<T>::f()':
x.cc:9:13: error: request for member 's' in '((X<T>*)this)->.c', which is of
pointer type 'C*' (maybe you meant to use '->' ?)
     this->c.s();
             ^

The ->.c part is bogus, that doesn't appear in the source, and isn't valid C++.

GCC 6 is correct:

x.cc: In instantiation of 'void X<T>::f() [with T = int]':
x.cc:16:7:   required from here
x.cc:9:13: error: request for member 's' in '((X<int>*)this)->X<int>::c', which
is of pointer type 'C*' (maybe you meant to use '->' ?)
     this->c.s();
     ~~~~~~~~^


If it's not a template we get ((X*)this)->X::c which is also correct.

Reply via email to