Skip to content

Commit

Permalink
Remove custom offsetof implementation
Browse files Browse the repository at this point in the history
Clang complains that "performing pointer subtraction with a null pointer
may have undefined behavior" and the whole code path doesn't seem to be
necessary anymore with current compilers.
  • Loading branch information
hahnjo authored and bernhardmgruber committed Mar 22, 2022
1 parent c0e6b8d commit 8e0e200
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions Vc/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,6 @@ static Vc_INTRINSIC void unreachable() { __assume(0); }

#define Vc_make_unique(name) Vc_CAT(Vc_,name,_,__LINE__)

#if defined(Vc_ICC) || defined(Vc_CLANG) || defined Vc_APPLECLANG
#define Vc_OFFSETOF(Type, member) (reinterpret_cast<const char *>(&reinterpret_cast<const Type *>(0)->member) - reinterpret_cast<const char *>(0))
#else
#define Vc_OFFSETOF(Type, member) offsetof(Type, member)
#endif

#if defined(Vc_NO_NOEXCEPT)
#define Vc_NOEXCEPT throw()
#else
Expand Down
2 changes: 1 addition & 1 deletion Vc/common/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Memory<V, Size, 0u, InitPadding> :
// accordingly
char *addr = reinterpret_cast<char *>(ptr);
typedef Memory<V, Size, 0u, false> MM;
addr -= Vc_OFFSETOF(MM, m_mem);
addr -= offsetof(MM, m_mem);
return *new(addr) MM;
}

Expand Down

0 comments on commit 8e0e200

Please sign in to comment.