Skip to content

Commit 31439f8

Browse files
hooddanielcfacebook-github-bot
authored andcommitted
Fix build error caused by -Werror=class-memaccess (#823)
Summary: 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` ``` Not using buckd because watchman isn't installed. yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’: yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess] memset(&(node->getLayout()), 0, sizeof(YGLayout)); ^ In file included from yoga/YGNode.h:11, from yoga/Utils.h:9, from yoga/Yoga.cpp:13: yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here struct YGLayout { ^~~~~~~~ cc1plus: all warnings being treated as errors Build failed: Command failed with exit code 1. stderr: yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’: yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess] memset(&(node->getLayout()), 0, sizeof(YGLayout)); ^ In file included from yoga/YGNode.h:11, from yoga/Utils.h:9, from yoga/Yoga.cpp:13: yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here struct YGLayout { ^~~~~~~~ cc1plus: all warnings being treated as errors When running <c++ preprocess_and_compile>. When building rule //:yoga#compile-Yoga.cpp.o9b5477b5,default. Parsing buck files: finished in 0.8 sec (100%) Building: finished in 2.2 sec (100%) 10/10 jobs, 1 updated Total time: 3.3 sec ``` Build Log After Fix command: `buck build //:yoga` ``` Not using buckd because watchman isn't installed. Parsing buck files: finished in 0.8 sec (100%) Building: finished in 0.6 sec (100%) 1/1 jobs, 0 updated Total time: 1.6 sec ``` All tests are passing Pull Request resolved: facebook/yoga#823 Reviewed By: davidaurelio Differential Revision: D10486023 Pulled By: passy fbshipit-source-id: e9de734c3ce6c45ea4a8edd5d78206901d85ca84
1 parent 1f394fa commit 31439f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ReactCommon/yoga/yoga/Yoga.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,9 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
18501850
}
18511851

18521852
static void YGZeroOutLayoutRecursivly(const YGNodeRef node) {
1853-
memset(&(node->getLayout()), 0, sizeof(YGLayout));
1853+
node->getLayout() = {};
1854+
node->setLayoutDimension(0, 0);
1855+
node->setLayoutDimension(0, 1);
18541856
node->setHasNewLayout(true);
18551857
node->cloneChildrenIfNeeded();
18561858
const uint32_t childCount = YGNodeGetChildCount(node);

0 commit comments

Comments
 (0)