public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3143] c++: Fix up value initialization of structs with zero width bitfields [PR102019]
@ 2021-08-25 20:36 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-08-25 20:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1ab84eda5548119908c4e24c6ad953dd7c00a5b7

commit r12-3143-g1ab84eda5548119908c4e24c6ad953dd7c00a5b7
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Aug 25 22:35:21 2021 +0200

    c++: Fix up value initialization of structs with zero width bitfields [PR102019]
    
    The removal of remove_zero_width_bit_fields, in addition to triggering
    some ABI issues that need solving anyway (ABI incompatibility between
    C and C++) also resulted in UB inside of gcc, we now call build_zero_init
    which calls build_int_cst on an integral type with TYPE_PRECISION of 0.
    
    Fixed by ignoring the zero width bitfields.  I understand
    build_value_init_noctor wants to initialize to 0 even unnamed bitfields
    (of non-zero width), at least until we have some CONSTRUCTOR flag that says
    that even all the padding bits should be cleared.
    
    2021-08-25  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/102019
            * init.c (build_value_init_noctor): Ignore unnamed zero-width
            bitfields.

Diff:
---
 gcc/cp/init.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 229c84e1d74..1426f9a5434 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -427,6 +427,11 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
 		      == NULL_TREE))
 		continue;
 
+	      /* Ignore unnamed zero-width bitfields.  */
+	      if (DECL_UNNAMED_BIT_FIELD (field)
+		  && integer_zerop (DECL_SIZE (field)))
+		continue;
+
 	      /* We could skip vfields and fields of types with
 		 user-defined constructors, but I think that won't improve
 		 performance at all; it should be simpler in general just


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-25 20:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 20:36 [gcc r12-3143] c++: Fix up value initialization of structs with zero width bitfields [PR102019] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).