re PR c++/10635 (ICE (segfault) when dereferencing an incomplete type casted from...
authorMark Mitchell <mark@codesourcery.com>
Thu, 12 Jun 2003 17:22:29 +0000 (17:22 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 12 Jun 2003 17:22:29 +0000 (17:22 +0000)
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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/cast1.C [new file with mode: 0644]

index 7e74f47b3b505b6690f02f3039d94cc451b5db51..787643c9e11fa08957a3caffb26d156e51823424 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-12  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10635
+       * typeck.c (build_c_cast): Check that the destination type is
+       complete.
+
 2003-06-11  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/10432
index 21068b321eb20930bf5cc8385ace55fbd754ebd9..051d9bc68e87e936a612d72ccb3ee7ca7a62603e 100644 (file)
@@ -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
index 704694ab33c69e16400192e07d17ccc1d44b067b..2dcfe1433d6dee5d2a5ae103c1b7a59e3eabe281 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-12  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10635
+       * g++.dg/expr/cast1.C: New test.
+
 2003-06-12  Roger Sayle  <roger@eyesopen.com>
 
        * 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 (file)
index 0000000..ee1adcc
--- /dev/null
@@ -0,0 +1,3 @@
+struct S; // { dg-error "forward" } 
+
+void f(S* p) { ((S) (*p)); } // { dg-error "" }