Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed undefined use of union in getAnyPtr #35051

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions FWCore/Utilities/interface/getAnyPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@

namespace edm {
template <typename T>
inline std::unique_ptr<T> getAnyPtr(void* p, int offset) {
// A union is used to avoid possible copies during the triple cast that would otherwise be needed.
// std::unique_ptr<T> edp(static_cast<T*>(static_cast<void *>(static_cast<unsigned char *>(p) + offset)));
union {
void* vp;
unsigned char* ucp;
T* tp;
} pointerUnion;
assert(p != nullptr);
pointerUnion.vp = p;
pointerUnion.ucp += offset;
return std::unique_ptr<T>(pointerUnion.tp);
inline std::unique_ptr<T> getAnyPtr(void *p, int offset) {
return std::unique_ptr<T>(static_cast<T *>(static_cast<void *>(static_cast<unsigned char *>(p) + offset)));
}
} // namespace edm

Expand Down