[llvm-commits] [llvm] r98843 - /llvm/trunk/include/llvm/ADT/SmallVector.h

Dan Gohman gohman at apple.com
Thu Mar 18 11:40:47 PDT 2010


Author: djg
Date: Thu Mar 18 13:40:47 2010
New Revision: 98843

URL: http://llvm.org/viewvc/llvm-project?rev=98843&view=rev
Log:
Fix a bug found by inspection; in the __GNUC__ code, the alignment
doesn't apply to the type, only to the variable, so subsequent uses
of U which expect it to be aligned weren't actually aligned.

Modified:
    llvm/trunk/include/llvm/ADT/SmallVector.h

Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=98843&r1=98842&r2=98843&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Thu Mar 18 13:40:47 2010
@@ -57,17 +57,18 @@
   // something else.  An array of char would work great, but might not be
   // aligned sufficiently.  Instead, we either use GCC extensions, or some
   // number of union instances for the space, which guarantee maximal alignment.
+  struct U {
 #ifdef __GNUC__
-  typedef char U;
-  U FirstEl __attribute__((aligned));
+    char X __attribute__((aligned));
 #else
-  union U {
-    double D;
-    long double LD;
-    long long L;
-    void *P;
-  } FirstEl;
+    union U {
+      double D;
+      long double LD;
+      long long L;
+      void *P;
+    } X;
 #endif
+  } FirstEl;
   // Space after 'FirstEl' is clobbered, do not add any instance vars after it.
   
 protected:





More information about the llvm-commits mailing list