This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] [PR15967] Fix ICE with ambiguous operator new
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: "Mark Mitchell" <mark at codesourcery dot com>
- Date: Tue, 15 Jun 2004 05:05:59 +0200
- Subject: Re: [C++ PATCH] [PR15967] Fix ICE with ambiguous operator new
Giovanni Bajo wrote:
> Tested on i686-pc-linux-gnu. OK for mainline? OK for 3.4.1 (looks
> trivial enough)?
Committed to trunk after approval by Mark within the bug audit trail (see the
PR in Bugzilla). After some discussion, I'm committing this less intrusive
patch to the 3.4 branch.
Giovanni Bajo
cp/
PR c++/15967
* search.c (build_new_1): Robustify.
testsuite/
PR c++/15967
* g++.dg/lookup/crash3.C: New test.
Index: init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.356.2.1
diff -c -3 -p -r1.356.2.1 init.c
*** init.c 19 Jan 2004 20:39:30 -0000 1.356.2.1
--- init.c 15 Jun 2004 01:49:28 -0000
*************** build_new_1 (tree exp)
*** 2052,2057 ****
--- 2052,2066 ----
args = tree_cons (NULL_TREE, size, placement);
/* Do name-lookup to find the appropriate operator. */
fns = lookup_fnfields (true_type, fnname, /*protect=*/2);
+ if (!fns)
+ {
+ /* See PR 15967. This should never happen (and it is
+ fixed correctly in mainline), but on the release branch
+ we prefer this less-intrusive approacch. */
+ error ("no suitable or ambiguous `%D' found in class `%T'",
+ fnname, true_type);
+ return error_mark_node;
+ }
if (TREE_CODE (fns) == TREE_LIST)
{
error ("request for member `%D' is ambiguous", fnname);
// { dg-do compile }
// Contributed by Wolfgang Wieser <wwieser at gmx dot de>
// PR c++/15967: ICE with ambiguous operator new
typedef unsigned int size_t;
struct A { void *operator new(size_t s){} };
struct B { void *operator new(size_t s){} };
struct C : A,B {};
int crash()
{
C *c=new C(); // { dg-error "ambiguous" }
}