Fix build error caused by -Werror=class-memaccess #823
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix-werror-class-memaccess"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
OS: Arch Linux
GCC Version: gcc (GCC) 8.2.1 20180831
Clang Version: 6.0.1 (tags/RELEASE_601/final)
Build Log Before Fix:
command:
buck build //:yoga
Build Log After Fix
command:
buck build //:yoga
All tests are passing
passy has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks for helping to make Yoga better.
I have a specific concern with using
static_cast<>
, and I believe that it isn’t necessary at all.The
memset
call is probably a relict from the times when Yoga was pure C.@@ -1851,7 +1851,9 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
}
while you are at it, please leave the place in a better state.
static_cast<>
sidesteps the type system where we can just leverage default constructor + assignment.@@ -1851,7 +1851,9 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
}
👍 I agree this is much better. When doing so, test results break because
YGLayout::YGLayout()
initializesdimensions({YGUndefined, YGUndefined})
instead ofdimensions({0, 0})
. After setting dimensions to zero after assignment, tests are passing.@@ -1851,7 +1851,9 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
}
@hooddanielc, @davidaurelio If the test results brake I think this looks like a bug of the constructor of
YGLayout
mustn't this be initialized to{0,0}
per default in the ctor ?@@ -1851,7 +1851,9 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
}
@woehrl01 That is what I thought at first, then I found some history in comments above
YGUndefined
definition.I think the alternatives of using default constructor or changing the constructor may be a breaking change. Could we add a new constructor to
YGLayout
? Does the C++ delegate constructor allow us to override part of that constructors initialization list?passy has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Pull request closed