You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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).
The text was updated successfully, but these errors were encountered:
Extended Description
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
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).
The text was updated successfully, but these errors were encountered: