error: cannot convert 'int*' to 'int A::*' for argument '1' to 'void blah(int A::*)' struct A; void blah(int A::*); struct A{ int a; }; template<typename T> //remove this line to make it work void hoho(){ blah(&A::a); } compiles on gcc up to early 4.0, icc and comeau
Subject: Re: New: rejects valid pointer to member "sstrasser at systemhaus-gruppe dot de" <gcc-bugzilla@gcc.gnu.org> writes: | error: cannot convert 'int*' to 'int A::*' for argument '1' to 'void blah(int A::*)' This is clearly a bug in GCC. -- Gaby
Confirmed.
This worked with 20050225, right before 4.0.0 was branched. But it failed with 20050325.
This is related to PR 20465 and PR 20381 which you fixed with: 2005-03-22 Nathan Sidwell <nathan@codesourcery.com> PR c++/20465 PR c++/20381 * typeck.c (build_ptrmemfunc): Allow OFFSET_REF when processing a template. Could you look into this?
It also fails with "4.1.0 20050308". I think this was caused by: 2005-03-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/19311 * init.c (build_offset_ref): Don't build non-dependent SCOPE_REF. * pt.c (build_non_dependent_expr): Don't build NON_DEPENDENT_EXPR for OFFSET_TYPE. * typeck.c (build_x_unary_op): Don't build non-dependent SCOPE_REF. Also set PTRMEM_OK_P for NON_DEPENDENT_EXPR. (build_unary_op): Handle building ADDR_EXPR of OFFSET_REF inside template.
Subject: Bug 20734 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: mmitchel@gcc.gnu.org 2005-04-06 05:35:50 Modified files: gcc/cp : cp-tree.def init.c typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: ptrmem13.C Log message: PR c++/20734 * cp-tree.def (OFFSET_REF): Correct comments. * init.c (build_offset_ref): Remove misleading comment. * typeck.c (build_unary_op): Handle pointer-to-member creation here, rather than ... (unary_complex_lvalue): ... here. PR c++/20734 * g++.dg/template/ptrmem13.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.94&r2=1.94.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.412.2.3&r2=1.412.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.616.2.4&r2=1.616.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.106&r2=1.5084.2.107 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem13.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 20734 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2005-04-06 05:38:34 Modified files: gcc/cp : cp-tree.def init.c typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: ptrmem13.C Log message: PR c++/20734 * cp-tree.def (OFFSET_REF): Correct comments. * init.c (build_offset_ref): Remove misleading comment. * typeck.c (build_unary_op): Handle pointer-to-member creation here, rather than ... (unary_complex_lvalue): ... here. PR c++/20734 * g++.dg/template/ptrmem13.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.94&r2=1.95 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.416&r2=1.417 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.622&r2=1.623 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5292&r2=1.5293 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem13.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed in 4.0.
the file which has led to the test case above compiles ok, too