Bug 15142 - [3.4/4.0 Regression] Internal compiler error when passing a string where a char* is expecteted in a throw statement
Bug#: 15142 Product:  gcc Version: 3.4.0
Host:  Target:  Build: 
Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: jason@redhat.com Reported By: micis@gmx.de
Component: c++ Target Milestone: 3.4.1
Summary: [3.4/4.0 Regression] Internal compiler error when passing a string where a char* is expecteted in a throw statement
Keywords:  ice-on-valid-code
Opened: 2004-04-26 08:45
Description:   Last confirmed: 2004-04-26 13:54 Opened: 2004-04-26 08:45
when compiling this small (and silly) program I get an internal compiler error:
bug34.cpp: In function `void SillyFunc()':
bug34.cpp:12: warning: cannot pass objects of non-POD type `struct std::string' 
through `...'; call will abort at runtime
bug34.cpp:12: internal compiler error: in cp_expr_size, at cp/cp-lang.c:347
Please submit a full bug report,

#include <string>
class Err
{
    public: Err(char *aErrText,...) {}
};

void SillyFunc()
{
    std::string fullname;
    throw Err("failed %s",fullname);
}

------- Comment #1 From Michael Cieslinski 2004-04-26 08:46 -------
Created an attachment (id=6164) [edit]
preprocessed source

------- Comment #2 From Andrew Pinski 2004-04-26 11:24 -------
Confirmed but not yet reduced.

------- Comment #3 From Wolfgang Bangerth 2004-04-26 13:54 -------
Here we go: 
----------------- 
struct B { 
    B() throw() { } 
    B(const B&) throw() { } 
}; 
 
struct X { 
    B a; 
    X& operator=(const X&); 
}; 
 
struct S { S(...); }; 
 
void SillyFunc() { 
  throw S(X()); 
} 
--------------------- 
 
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc 
x.cc: In function `void SillyFunc()': 
x.cc:14: warning: cannot pass objects of non-POD type `struct X' through 
`...';  
   call will abort at runtime 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc: In function `void SillyFunc()': 
x.cc:14: warning: cannot pass objects of non-POD type `struct X' through 
`...';  
call will abort at runtime 
x.cc:14: internal compiler error: in cp_expr_size, at cp/cp-lang.c:347 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc: In function `void SillyFunc()': 
x.cc:14: warning: cannot pass objects of non-POD type `struct X' through 
`...';  
call will abort at runtime 
x.cc:14: internal compiler error: in cp_expr_size, at cp/cp-lang.c:347 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W. 

------- Comment #4 From Andrew Pinski 2004-04-26 15:01 -------
This looks similar to bug 11971 which was fixed for 3.4.0.

------- Comment #5 From Wolfgang Bangerth 2004-04-26 15:37 -------
Except that this one isn't. 
W. 

------- Comment #6 From Mark Mitchell 2004-05-31 21:39 -------
Jason --

This is caused by the call_builtin_trap() stuff that you added; that function
wants to make a TARGET_EXPR and the backend wants to copy stuff around.  Instead
of making a TARGET_EXPR, why not dereference a NULL pointer?

(I think I'd rather that we just issue an error, but maybe a careful reading of
the standard does not permit an error here?)

In any case, please fix this regression.

Thanks,

-- Mark

------- Comment #7 From CVS Commits 2004-06-01 20:28 -------
Subject: Bug 15142

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jason@gcc.gnu.org	2004-06-01 20:28:26

Modified files:
	gcc/cp         : ChangeLog call.c 

Log message:
	PR c++/15142
	* call.c (call_builtin_trap): Remove type parm.
	(convert_arg_to_ellipsis): Change a non-POD argument to integer type.
	(build_x_va_arg): Dereference a null pointer for a non-POD argument.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4075&r2=1.4076
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.479&r2=1.480


------- Comment #8 From CVS Commits 2004-06-01 20:28 -------
Subject: Bug 15142

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jason@gcc.gnu.org	2004-06-01 20:28:38

Added files:
	gcc/testsuite/g++.dg/overload: ellipsis1.C 

Log message:
	PR c++/15142
	* call.c (call_builtin_trap): Remove type parm.
	(convert_arg_to_ellipsis): Change a non-POD argument to integer type.
	(build_x_va_arg): Dereference a null pointer for a non-POD argument.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/ellipsis1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1


------- Comment #9 From CVS Commits 2004-06-02 20:30 -------
Subject: Bug 15142

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	jason@gcc.gnu.org	2004-06-02 20:30:48

Modified files:
	gcc/cp         : ChangeLog call.c 

Log message:
	PR c++/15142
	* call.c (call_builtin_trap): Remove type parm.
	(convert_arg_to_ellipsis): Change a non-POD argument to integer type.
	(build_x_va_arg): Dereference a null pointer for a non-POD argument.

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.113&r2=1.3892.2.114
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.17&r2=1.452.2.18


------- Comment #10 From Jason Merrill 2004-06-02 20:31 -------
fixed