-
Notifications
You must be signed in to change notification settings - Fork 202
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
Fix compilation error on gcc 9.1 #441
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure I understand this fix. Isn't the compiler error telling us that sizeof test somehow failed and we are using memcpy for not matching types?
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.
No. gcc 9.1 is only complaining about the type mismatch between source and destination of memcpy op. The memcpy function won't called if their types don't match, but this is run-time behavior that won't be taken into account at compile time.
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.
I may be missing something here and we would need to have a bit more information about which actual invocation of _FillPrimvarData is generating this error.
FWIW. There is one possibility where we will have a destination as
Vec4f
and source asVec3f
when filling color with alpha buffer. In this case, we should never enter the memcpy section...and the error should never be generated.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.
Indeed the invocation is from where the source is Vec3f and the destination is Vec4f. And we indeed don't enter the memcpy section at run time. But the compiler won't examine run-time code path at compile time, that is why it still generate the error.
The fix has been validated on gcc 9.1.
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.
One detail, sizeof is a constant expression, the compiler should know that it doesn't enter this condition. Maybe it's a bug in the compiler and this is why we never saw it before.
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.
I guess even if we had this memcpy call inside a if(false) clause the compiler would still generate this error. More because of compiler strictness, I am not sure if it is a bug.
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.
Looking at C++17 and what if const expression can do...you may be right that compiler won't help us here because of value dependency.
OK, you convinced me. Thx.