re PR c++/49395 (Non-class prvalues seem to have cv-qualification with GCC)
authorJason Merrill <jason@redhat.com>
Thu, 23 Jun 2011 16:52:41 +0000 (12:52 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Jun 2011 16:52:41 +0000 (12:52 -0400)
PR c++/49395
* init.c (build_zero_init_1): Strip cv-quals from scalar types.

From-SVN: r175339

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/ref18.C [new file with mode: 0644]

index 64a5807260c3d3d8f06b8e3d1fec5cbfe4830790..a8fbf7ba1796d267d613e6040dc650d335ddd20d 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49395
+       * init.c (build_zero_init_1): Strip cv-quals from scalar types.
+
        PR c++/36435
        * pt.c (most_specialized_instantiation): Do check return types.
 
index 3c347a4521f983a2c84914731bf5f0185c9a1754..62b68f2b9ea6a81e8575705813ce34b561a182d4 100644 (file)
@@ -176,7 +176,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
        initialized are initialized to zero.  */
     ;
   else if (SCALAR_TYPE_P (type))
-    init = convert (type, integer_zero_node);
+    init = convert (cv_unqualified (type), integer_zero_node);
   else if (CLASS_TYPE_P (type))
     {
       tree field;
index 8c1f88650268c084921fe4cb9be9cc1987e2c86d..dda6cfffeccc0cebd0f4bf71428990c384fad751 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49395
+       * g++.dg/init/ref18.C: New.
+
        PR c++/36435
        * g++.dg/template/partial9.C: New.
 
diff --git a/gcc/testsuite/g++.dg/init/ref18.C b/gcc/testsuite/g++.dg/init/ref18.C
new file mode 100644 (file)
index 0000000..e704077
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/49395
+
+volatile int foo();
+struct A { volatile int i; };
+typedef volatile int vi;
+
+volatile int i;
+
+const int& ir1 = foo();
+//const int& ir2 = A().i;  // line 8
+const int& ir3 = static_cast<volatile int>(i);
+const int& ir4 = vi();  // line 10