[C++] PR 51219

Submitted by Paolo Carlini on Jan. 28, 2014, 6:37 p.m.

Details

Message ID 52E7F8CE.3010306@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Jan. 28, 2014, 6:37 p.m.
... by the way, I don't understand why we are appending the constructor 
at all for the unnamed bit-field?!? Eg, what about the below?

Thanks,
Paolo.

////////////////////

Comments

Jason Merrill Jan. 31, 2014, 10 p.m.
On 01/28/2014 01:37 PM, Paolo Carlini wrote:
> ... by the way, I don't understand why we are appending the constructor
> at all for the unnamed bit-field?!? Eg, what about the below?

I agree, it doesn't seem necessary; output_constructor deals fine with a 
sparse CONSTRUCTOR.  This patch is OK.

Jason
Paolo Carlini Feb. 1, 2014, 9:25 a.m.
On 01/31/2014 11:00 PM, Jason Merrill wrote:
> On 01/28/2014 01:37 PM, Paolo Carlini wrote:
>> ... by the way, I don't understand why we are appending the constructor
>> at all for the unnamed bit-field?!? Eg, what about the below?
>
> I agree, it doesn't seem necessary; output_constructor deals fine with 
> a sparse CONSTRUCTOR.  This patch is OK.
Thanks, applied!

Paolo.

Patch hide | download patch | download mbox

Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c	(revision 207199)
+++ cp/typeck2.c	(working copy)
@@ -1268,11 +1268,7 @@  process_init_constructor_record (tree type, tree i
       tree type;
 
       if (!DECL_NAME (field) && DECL_C_BIT_FIELD (field))
-	{
-	  flags |= picflag_from_initializer (integer_zero_node);
-	  CONSTRUCTOR_APPEND_ELT (v, field, integer_zero_node);
-	  continue;
-	}
+	continue;
 
       if (TREE_CODE (field) != FIELD_DECL || DECL_ARTIFICIAL (field))
 	continue;
Index: testsuite/g++.dg/init/bitfield5.C
===================================================================
--- testsuite/g++.dg/init/bitfield5.C	(revision 0)
+++ testsuite/g++.dg/init/bitfield5.C	(working copy)
@@ -0,0 +1,12 @@ 
+// PR c++/51219
+
+struct A
+{
+  int i;
+  int : 8;
+};
+
+void foo()
+{
+  A a = { 0 };
+}