[LLVMbugs] [Bug 104] [c++] C++ Frontend lays out superclasses like anonymous bitfields!

bugzilla-daemon at zion.cs.uiuc.edu bugzilla-daemon at zion.cs.uiuc.edu
Sun Nov 9 08:57:00 PST 2003


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=104

sabre at nondot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
             Status|ASSIGNED                    |RESOLVED
           Keywords|quality-of-implementation   |miscompilation
         Resolution|                            |FIXED
            Summary|[c++] Rampant type-unsafety |[c++] C++ Frontend lays out
                   |for no apparent reason      |superclasses like anonymous
                   |                            |bitfields!



------- Additional Comments From sabre at nondot.org  2003-11-09 10:57 -------
Whoa, this is scary.  The C++ front-end would always lay out base classes as
anonymous bitfield references, causing no end of trouble.  I would not be
suprised if this fixes some of the problems we are having with C++ codes: this
could cause miscompilations.

$ diff -u llvm-types.c~ llvm-types.c
--- llvm-types.c~       2003-11-04 13:25:46.000000000 -0600
+++ llvm-types.c        2003-11-09 10:37:09.000000000 -0600
@@ -633,7 +633,8 @@
     ElementAlignments[*Idx] = ByteAlignment;
     *Size = StartOffset/8 + llvm_type_get_size(Ty);
     ++*Idx;
-  } else if (DECL_NAME(field) == 0) {       /* Is this an anonymous bitfield? */
+  } else if (DECL_NAME(field) == 0 &&      /* Is this an anonymous bitfield? */
+             DECL_BIT_FIELD(field)) {
     unsigned NumPads;
     /* Is it attempting to align the current offset to some value? */
     if (GetDeclSize(field) == 0) {

--- 

With this patch, we now get:
%struct.derived = type { %struct.base, %struct.contained }

As expected.

-Chris



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list