Bug 47172 - [4.6 Regression] [C++0x] cannot call member function without object
[4.6 Regression] [C++0x] cannot call member function without object
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.6.0
: P1 normal
: 4.6.0
Assigned To: Dodji Seketeli
: rejects-valid
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-04 21:42 UTC by Marc Glisse
Modified: 2011-02-17 06:52 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.5, 4.5.2
Known to fail:
Last reconfirmed: 2011-01-04 22:28:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2011-01-04 21:42:32 UTC
The following code fails to compile with -std=c++0x, but compiles with c++98 or if I change the prototype of f to make it return void. It doesn't look like PR 46731.

struct A
{
    int f() const;
};

template <class T>
struct B : A { };

template <class T>
struct C : B<T>
{
    void g();
};

template <class T>
void C<T>::g()
{
    A::f();
}

bug.cpp:18:11: error: cannot call member function 'int A::f() const' without object
Comment 1 Jonathan Wakely 2011-01-04 22:28:48 UTC
confirmed as a regression in 4.6
Comment 2 H.J. Lu 2011-01-04 22:49:51 UTC
It is caused by revision 166167:

http://gcc.gnu.org/ml/gcc-cvs/2010-11/msg00053.html
Comment 3 Dodji Seketeli 2011-02-09 14:27:44 UTC
Candidate patch posted to http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00603.html
Comment 4 Dodji Seketeli 2011-02-11 07:33:57 UTC
Author: dodji
Date: Fri Feb 11 07:33:53 2011
New Revision: 170045

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170045
Log:
Fix PR c++/47172

gcc/cp/

	PR c++/47172
	* pt.c (finish_call_expr): Consider a call expression that has a
	dependent "this" pointer as being dependent.  Add comments.
	(dependent_type_p, type_dependent_expression_p): Update comments.

gcc/testsuite/

	* g++.dg/template/inherit6.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/inherit6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Dodji Seketeli 2011-02-11 10:54:41 UTC
Fixed in trunk (4.6)
Comment 6 H.J. Lu 2011-02-11 15:32:08 UTC
I don't think it is fixed. See PR 47697.
Comment 7 Dodji Seketeli 2011-02-11 17:27:04 UTC
Author: dodji
Date: Fri Feb 11 17:27:00 2011
New Revision: 170055

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170055
Log:
Revert "Fix PR c++/47172"

gcc/cp/

	* pt.c (finish_call_expr, dependent_type_p)
	(type_dependent_expression_p): Revert the previous attempt to fix
	PR c++/47172.

gcc/testsuite/

    	* g++.dg/template/inherit6.C: Reverted.

Removed:
    trunk/gcc/testsuite/g++.dg/template/inherit6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Eric Botcazou 2011-02-14 08:24:19 UTC
Adjust.
Comment 9 Dodji Seketeli 2011-02-17 06:50:40 UTC
Author: dodji
Date: Thu Feb 17 06:50:35 2011
New Revision: 170240

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170240
Log:
Fix PR c++/47172

gcc/cp/

	PR c++/47172
	* pt.c (finish_call_expr): Consider a call expression that has a
	dependent "this" pointer as being dependent.  Add comments.
	(dependent_type_p, type_dependent_expression_p): Update comments.

gcc/testsuite/

	* g++.dg/template/inherit6.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/inherit6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 10 Dodji Seketeli 2011-02-17 06:52:04 UTC
Hopefully fixed in trunk (4.6) this time.