User account creation filtered due to spam.

Bug 16810 - [3.4/4.0 Regression] Legal C++ program with cast gives ICE in build_ptrmemfunc
Summary: [3.4/4.0 Regression] Legal C++ program with cast gives ICE in build_ptrmemfunc
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.2
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-07-28 21:42 UTC by Steve Ellcey
Modified: 2004-10-30 21:11 UTC (History)
1 user (show)

See Also:
Host: ia64-hp-hpux11.22
Target: ia64-hp-hpux11.22
Build: ia64-hp-hpux11.22
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-07-28 21:48:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Ellcey 2004-07-28 21:42:20 UTC
The following C++ program will not compile with g++ versions 3.4.1 or 3.5,
I tried the ia64-hp-hpux11.22 platform as well as hppa-hp-hpux11.00.


struct C {
    virtual void f() {}
};

struct B {virtual ~B() {} };

class D : public B, public C
{
public:
    virtual void f() {}
};

typedef void ( C::*FP)();
typedef void ( D::*D_f)();

int main() {
  D *d = new D();
  C *c = d;

  const FP fptr = (FP) &D::f;;
  (d->* (D_f)fptr)();
}

-----------------------------------

/usr/local/bin/g++ -c x.C
x.C: In function `int main()':
x.C:21: internal compiler error: in build_ptrmemfunc, at cp/typeck.c:5512
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2004-07-28 21:48:35 UTC
: Search converges between 2003-07-28-trunk (#307) and 2003-07-29-trunk (#308).

Confirmed.
Comment 2 Andrew Pinski 2004-07-28 21:48:41 UTC
: Search converges between 2003-07-28-trunk (#307) and 2003-07-29-trunk (#308).

Confirmed.
Comment 3 Mark Mitchell 2004-08-01 20:40:57 UTC
Working on a fix.
Comment 4 CVS Commits 2004-08-02 01:56:42 UTC
Subject: Bug 16810

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-08-02 01:56:33

Modified files:
	gcc/cp         : ChangeLog call.c cp-tree.h decl.c pt.c 
	                 semantics.c typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/inherit: ptrmem2.C 
	gcc/testsuite/g++.dg/init: null1.C 
	gcc/testsuite/g++.dg/parse: namespace10.C 

Log message:
	PR c++/16338
	* cp-tree.h (DECL_INTEGRAL_CONSTANT_VAR_P): New macro.
	* call.c (null_ptr_cst_p): Handle variables with constant
	initializers.
	* pt.c (convert_nontype_argument): Use
	DECL_INTEGRAL_CONSTANT_VAR_P.
	* semantics.c (finish_id_expression): Likewise.
	
	PR c++~/16489
	* decl.c (duplicate_decls): Reject duplicate namespace
	declarations.
	
	PR c++/16810
	* typeck.c (build_ptrmemfunc): Loosen assertion.
	
	PR c++/16338
	* g++.dg/init/null1.C: New test.
	* g++.dg/tc1/dr76.C: Adjust error marker.
	
	PR c++/16489
	* g++.dg/parse/namespace10.C: New test.
	
	PR c++/16810
	* g++.dg/inherit/ptrmem2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.136&r2=1.3892.2.137
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.19&r2=1.452.2.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.946.4.14&r2=1.946.4.15
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.21&r2=1.1174.2.22
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.34&r2=1.816.2.35
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.381.4.11&r2=1.381.4.12
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.21&r2=1.519.2.22
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.238&r2=1.3389.2.239
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/ptrmem2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/null1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/namespace10.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 5 CVS Commits 2004-08-02 01:58:55 UTC
Subject: Bug 16810

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-08-02 01:58:52

Modified files:
	gcc/cp         : ChangeLog call.c cp-tree.h decl.c pt.c 
	                 semantics.c typeck.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/tc1: dr76.C 
Added files:
	gcc/testsuite/g++.dg/inherit: ptrmem2.C 
	gcc/testsuite/g++.dg/init: null1.C 
	gcc/testsuite/g++.dg/parse: namespace10.C 

Log message:
	PR c++/16338
	* cp-tree.h (DECL_INTEGRAL_CONSTANT_VAR_P): New macro.
	* call.c (null_ptr_cst_p): Handle variables with constant
	initializers.
	* pt.c (convert_nontype_argument): Use
	DECL_INTEGRAL_CONSTANT_VAR_P.
	* semantics.c (finish_id_expression): Likewise.
	
	PR c++~/16489
	* decl.c (duplicate_decls): Reject duplicate namespace
	declarations.
	
	PR c++/16810
	* typeck.c (build_ptrmemfunc): Loosen assertion.
	
	PR c++/16338
	* g++.dg/init/null1.C: New test.
	* g++.dg/tc1/dr76.C: Adjust error marker.
	
	PR c++/16489
	* g++.dg/parse/namespace10.C: New test.
	
	PR c++/16810
	* g++.dg/inherit/ptrmem2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4254&r2=1.4255
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.496&r2=1.497
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1026&r2=1.1027
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1265&r2=1.1266
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.898&r2=1.899
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.420&r2=1.421
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.565&r2=1.566
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4079&r2=1.4080
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/ptrmem2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/null1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/namespace10.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/tc1/dr76.C.diff?cvsroot=gcc&r1=1.2&r2=1.3

Comment 6 Mark Mitchell 2004-08-02 02:01:38 UTC
Fixed in GCC 3.4.2 and GCC 3.5.