-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
don't violate strict aliasing with reinterpret_cast #146
Conversation
there are some plugins which have the same problem (functions are |
plugin/common/plugin.h
Outdated
@@ -57,15 +58,16 @@ class BaseCreator : public IPluginCreator | |||
template <typename T> | |||
void write(char*& buffer, const T& val) | |||
{ | |||
*reinterpret_cast<T*>(buffer) = val; | |||
std::memcpy(buffer, &t, sizeof(T)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&val instead of &t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely! I'm away from a machine with an nvidia graphics card for some time, so I'll have to wait to verify everything (but I'll make this change for sure)
@@ -579,14 +579,15 @@ class UffPoolPluginV2 : public IPluginV2IOExt | |||
template <typename T> | |||
void write(char*& buffer, const T& val) const | |||
{ | |||
*reinterpret_cast<T*>(buffer) = val; | |||
std::memcpy(buffer, &t, sizeof(T)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&val instead of &t?
Signed-off-by: Tom Peters <[email protected]>
5db69fc
to
8339fbb
Compare
@tdp2110 can you please incorporate the review changes? Thanks. |
@rajeevsrao I believe it is incorporated. |
Signed-off-by: Tom Peters [email protected]