[patch] Fix PR c++/27952

Lee Millward lee.millward@gmail.com
Sat Jun 10 14:05:00 GMT 2006


Hi,

Currently the C++ front-end seg faults on the following invalid testcases:

Test 1:

struct A { virtual ~A() {} };
struct B : A, virtual A {};
struct C : A, B {};
C c;

Test 2:

struct A {};
struct B : A, virtual A {};
struct C : B {};

The seg faults are triggered inside decay_conversion and initialize_local_var,
both of couldn't handle NULL parameters so the first part of the patch
is adding
those checks into the two affected functions.

After the seg fault had been fixed inside decay_conversion the
following assertion
was triggered inside build_special_member_call a few lines down from
the call to decay_conversion, so the final portion of the patch is to
make build_special_member_call
return early if decay_conversion failed, avoiding the ICE.

Bootstrapped and regression tested on i686-pc-linux-gnu with no new failures.
Ok for mainline?

Cheers,
Lee.

:ADDPATCH C++:

cp/

2006-06-10  Lee Millward  <lee.millward@gmail.com>

       PR c++/27952
       * typeck2.c (decay_conversion): Robustify.
       * decl.c (initialize_local_var): Likewise.
       * call.c (build_special_member_call): Return early if
       decay_conversion fails.

testsuite/

2006-06-10  Lee Millward  <lee.millward@gmail.com>

       PR c++/27952
       * g++.dg/inherit/multiple2.C: New test.
       * g++.dg/inherit/multiple3.C: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr27952.patch
Type: text/x-patch
Size: 2255 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060610/85bc0c79/attachment.bin>


More information about the Gcc-patches mailing list