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

don't violate strict aliasing with reinterpret_cast #146

Merged
merged 1 commit into from
Mar 19, 2021

Conversation

tdp2110
Copy link
Contributor

@tdp2110 tdp2110 commented Oct 1, 2019

Signed-off-by: Tom Peters thomas.d.peters@gmail.com

@tdp2110
Copy link
Contributor Author

tdp2110 commented Oct 1, 2019

there are some plugins which have the same problem (functions are writeToBuffer and readToBuffer there). I'll fix those up too

@@ -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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&val instead of &t?

Copy link
Contributor Author

@tdp2110 tdp2110 Oct 16, 2019

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));
Copy link
Collaborator

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 <thomas.d.peters@gmail.com>
@tdp2110 tdp2110 force-pushed the tom/strict-aliasing branch from 5db69fc to 8339fbb Compare October 16, 2019 18:58
@rajeevsrao
Copy link
Collaborator

@tdp2110 can you please incorporate the review changes? Thanks.

@tdp2110
Copy link
Contributor Author

tdp2110 commented Jan 12, 2021

@rajeevsrao I believe it is incorporated.

@rajeevsrao rajeevsrao merged commit 0dcade2 into NVIDIA:master Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants