gcc 4.1.2 emits the following warning on SmallVector: llvm/include/llvm/ADT/SmallVector.h:46: warning: dereferencing type-punned pointer will break strict-aliasing rules This appears to be due to the use of a union: template <typename T> class SmallVectorImpl { T *Begin, *End, *Capacity; // Allocate raw space for N elements of type T. If T has a ctor or dtor, we // don't want it to be automatically run, so we need to represent the space as // 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. protected: union U { double D; long double LD; long long L; void *P; } FirstEl; // Space after 'FirstEl' is clobbered, do not add any instance vars after it. public: // Default ctor - Initialize to empty. SmallVectorImpl(unsigned N) : Begin((T*)&FirstEl), End((T*)&FirstEl), Capacity((T*)&FirstEl+N) { } Line 46 being the one with where Begin, End and Capacity are being assigned. The trouble is that you aren't allowed to put a "T" in the union anyways (otherwise, that would be a neat hack to preserve the type without going through the constructor).
Created attachment 408 [details] test patch Please try this patch. If it works (silences the warnings), I'll commit it. Thanks. -Chris
Patch works for me.
Nicholas, thanks for verifying. Fixed, patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061002/038404.html -Chris