commit 8f1186d00e9f78a8b64f678cc322332568bbec59
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 22 16:34:53 2011 -0400
PR c++/49395
* init.c (build_zero_init_1): Strip cv-quals from scalar types.
@@ -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;
new file mode 100644
@@ -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