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

The sign problem caused by the C bit field #845

Closed
1 task
anyktx opened this issue Jan 5, 2019 · 2 comments
Closed
1 task

The sign problem caused by the C bit field #845

anyktx opened this issue Jan 5, 2019 · 2 comments

Comments

@anyktx
Copy link

anyktx commented Jan 5, 2019

Report

Issues and Steps to Reproduce

I used Visual Studio 2017 to code and compile, and some of the properties went wrong when I set the Style property of YGNode and got the layout results.

When I looked at the definitions of YGStylet and YGLayout, I found that some of the properties were bitfields used. In this case, having this property causes a sign problem. For example, the value of flexDirection is [0,3], when the value is 2 or 3, the bit field that USES two bits will take the previous bit as the symbol, resulting in a negative value. Without experimenting with other compilers, there may not be such a problem, but in Visual Studio such a problem does exist. The properties found to have this problem exist in almost all the properties that use bit fields.

Link to Code

https://github.com/facebook/yoga/blob/master/tests/YGFlexDirectionTest.cpp
This test won't work well in Visual Studio,

@zcbenz
Copy link
Contributor

zcbenz commented Jan 27, 2019

I can also reproduce this problem, in my case Yoga crashed directly because of wrong flexDirection value.

zcbenz added a commit to yue/yue that referenced this issue Jan 27, 2019
@Adlai-Holler
Copy link
Contributor

This is blocking my build when I try to import YGNode.h into a C++ context – the compiler errors with "Implicit truncation to bitfield will change value from 4 to -4." I tried changing the enum definition to be unsigned instead of int but that no workm.

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 a pull request may close this issue.

4 participants