This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] PR c++/39637


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

In this PR, we crash (on assert) in dependent_type_p(type), called by
cxx_sizeof_or_alignof_type because the former function expects the
processing_template_decl flag to be set when TYPE is a TEMPLATE_TYPE_PARM.

Using the more robust function uses_template_params instead of dependent_type_p
seems to address the issue.

The patch has been bootstrapped and regtested on amd64 for c++ and java.

OK for trunk ?

ps: I am not sure if it should be applied to 4.3.3 and 4.4 as it's not tagged as
a regression (yet).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Remi - http://enigmail.mozdev.org

iEYEARECAAYFAknaGtQACgkQPejI7lrem2FkIgCeIFKJU/jvNtD8fuOPowvQ1WIW
NH8AnjZ9IDuBWWyAvlrJUFQwqzaQsCJV
=0u2o
-----END PGP SIGNATURE-----
commit a41f3ef799592d99077d61bc4e5d49180d9cd241
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Mon Apr 6 16:50:09 2009 +0200

    Fix candidate for PR c++/39637
    
    gcc/cp/ChangeLog:
    2009-04-06  Dodji Seketeli  <dodji@redhat.com>
    	PR c++/39637
    	* typeck.c (cxx_sizeof_or_alignof_type): Use
    	uses_template_parms instead of dependent_type_p.
    
    gcc/testsuite/ChangeLog
    2009-04-06  Dodji Seketeli  <dodji@redhat.com>
    	PRc++/39637
    	* g++.dg/cpp0x/variadic-crash2.C: New test.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index fe791f3..b4d3d55 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1322,7 +1322,7 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
       value = size_one_node;
     }
 
-  dependent_p = dependent_type_p (type);
+  dependent_p = uses_template_parms (type);
   if (!dependent_p)
     complete_type (type);
   if (dependent_p
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C
new file mode 100644
index 0000000..8fc1334
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C
@@ -0,0 +1,18 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++/39637
+// { dg-options "-std=gnu++0x" }
+// { dg-do "compile" }
+
+template<class... Types>
+void
+f(Types...)
+{
+  enum {e = sizeof(Types)}; // { dg-error "enumerator value for 'e' is not an integer constant" }
+};
+
+int
+main()
+{
+    f(0);
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]