From: Mark Mitchell Date: Thu, 12 Jun 2003 17:22:29 +0000 (+0000) Subject: re PR c++/10635 (ICE (segfault) when dereferencing an incomplete type casted from... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=79b59cc3d3896f109992cee1bbba17ee255c334d;p=gcc.git re PR c++/10635 (ICE (segfault) when dereferencing an incomplete type casted from a void pointer) PR c++/10635 * typeck.c (build_c_cast): Check that the destination type is complete. PR c++/10635 * g++.dg/expr/cast1.C: New test. [[Split portion of a mixed commit.]] From-SVN: r67840.2 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e74f47b3b5..787643c9e11 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-06-12 Mark Mitchell + + PR c++/10635 + * typeck.c (build_c_cast): Check that the destination type is + complete. + 2003-06-11 Mark Mitchell PR c++/10432 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 21068b321eb..051d9bc68e8 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5189,6 +5189,10 @@ build_c_cast (type, expr) value = convert_to_void (value, /*implicit=*/NULL); return value; } + + if (!complete_type_or_else (type, NULL_TREE)) + return error_mark_node; + /* Convert functions and arrays to pointers and convert references to their expanded types, but don't convert any other types. If, however, we are diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 704694ab33c..2dcfe1433d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-06-12 Mark Mitchell + + PR c++/10635 + * g++.dg/expr/cast1.C: New test. + 2003-06-12 Roger Sayle * gcc.dg/builtins-21.c: New test case. diff --git a/gcc/testsuite/g++.dg/expr/cast1.C b/gcc/testsuite/g++.dg/expr/cast1.C new file mode 100644 index 00000000000..ee1adcc3d23 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cast1.C @@ -0,0 +1,3 @@ +struct S; // { dg-error "forward" } + +void f(S* p) { ((S) (*p)); } // { dg-error "" }