Fix a bug found by inspection; in the __GNUC__ code, the alignment
authorDan Gohman <gohman@apple.com>
Thu, 18 Mar 2010 18:40:47 +0000 (18:40 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 18 Mar 2010 18:40:47 +0000 (18:40 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98843 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallVector.h

index 89acefd0618675c3bbc6c98bdfbb0a4303276a80..c4507a917f3e22c36b8a11f0b01ed098a693e1d4 100644 (file)
@@ -57,17 +57,18 @@ protected:
   // 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: