public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94799] New: [7.2+ Regression] Calling a member template function fails
@ 2020-04-27 13:57 ojman101 at protonmail dot com
  2020-04-27 15:53 ` [Bug c++/94799] [8/9/10 Regression] " mpolacek at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: ojman101 at protonmail dot com @ 2020-04-27 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94799
           Summary: [7.2+ Regression] Calling a member template function
                    fails
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ojman101 at protonmail dot com
  Target Milestone: ---

>From gcc version 7.2 and upwards this c++ code, using a member template
function look-up, fails to compile:

template <typename T>
struct A {
    int a() {
        return 42;
    }
};

template <typename T>
struct B {
    int b(A<T> *p) {
        return p->template A<T>::a();
    }
};

int main() {
    A<int> a;
    B<int> b;
    return b.b(&a);
}

On gcc version 9.3.0 (Gentoo 9.3.0 p2), this output is generated:

main.cc: In member function 'int B<T>::b(A<T>*)':
main.cc:11:32: error: expected ';' before '::' token
   11 |         return p->template A<T>::a();
      |                                ^~
      |                                ;
main.cc:11:34: error: '::a' has not been declared
   11 |         return p->template A<T>::a();
      |                                  ^
main.cc: In instantiation of 'int B<T>::b(A<T>*) [with T = int]':
main.cc:18:18:   required from here
main.cc:11:28: error: 'A' is not a member template function
   11 |         return p->template A<T>::a();
      |                ~~~~~~~~~~~~^~~~

This code successfully compiles on new versions of clang, icc and msvc as well
as gcc versions before 7.2.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-10-28 19:27 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 13:57 [Bug c++/94799] New: [7.2+ Regression] Calling a member template function fails ojman101 at protonmail dot com
2020-04-27 15:53 ` [Bug c++/94799] [8/9/10 Regression] " mpolacek at gcc dot gnu.org
2020-04-27 15:58 ` mpolacek at gcc dot gnu.org
2020-04-27 16:34 ` rguenth at gcc dot gnu.org
2020-04-27 19:24 ` [Bug c++/94799] [8/9/10 " mpolacek at gcc dot gnu.org
2020-04-28  0:51 ` mpolacek at gcc dot gnu.org
2020-04-28 23:43 ` mpolacek at gcc dot gnu.org
2020-04-29  4:11 ` mpolacek at gcc dot gnu.org
2020-05-05 14:19 ` [Bug c++/94799] [8/9/10/11 " cvs-commit at gcc dot gnu.org
2020-05-05 14:21 ` [Bug c++/94799] [8/9/10 " mpolacek at gcc dot gnu.org
2020-05-15  9:52 ` reichelt at gcc dot gnu.org
2020-05-15 12:43 ` mpolacek at gcc dot gnu.org
2020-08-17 10:10 ` reichelt at gcc dot gnu.org
2020-08-17 17:32 ` mpolacek at gcc dot gnu.org
2020-10-19 21:03 ` mpolacek at gcc dot gnu.org
2020-10-20  0:53 ` mpolacek at gcc dot gnu.org
2020-10-24 18:25 ` mpolacek at gcc dot gnu.org
2020-10-28 19:26 ` cvs-commit at gcc dot gnu.org
2020-10-28 19:27 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).