diff mbox

Fix PR c++/45908

Message ID 201010061636.17678.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Oct. 6, 2010, 2:36 p.m. UTC
This is an ICE caused by my fix for PR middle-end/44100
  http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01277.html

The compiler passes an incomplete type to fold_offsetof and this is caught by 
an assertion downhill.  Fixed by adding the obvious check.

Tested on i586-suse-linux, applied on the mainline as obvious.


2010-10-06  Eric Botcazou  <ebotcazou@adacore.com>

	PR c++/45908
	* typeck.c (cp_build_addr_expr_1): Add check for incomplete types in
	code folding offsetof-like computations.


2010-10-06  Eric Botcazou  <ebotcazou@adacore.com>

	* g++.dg/cpp0x/pr45908.C: New test.
diff mbox

Patch

Index: typeck.c
===================================================================
--- typeck.c	(revision 164827)
+++ typeck.c	(working copy)
@@ -4940,6 +4940,7 @@  cp_build_addr_expr_1 (tree arg, bool str
       && TREE_CODE (argtype) != METHOD_TYPE
       && argtype != unknown_type_node
       && (val = get_base_address (arg))
+      && COMPLETE_TYPE_P (TREE_TYPE (val))
       && TREE_CODE (val) == INDIRECT_REF
       && TREE_CONSTANT (TREE_OPERAND (val, 0)))
     {