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

Evaluation order is not guaranteed #2

Open
ChristopheLorenz opened this issue Oct 17, 2018 · 1 comment
Open

Evaluation order is not guaranteed #2

ChristopheLorenz opened this issue Oct 17, 2018 · 1 comment

Comments

@ChristopheLorenz
Copy link

ChristopheLorenz commented Oct 17, 2018

In the source SDL_Arduino_INA3221.cpp

Line 71 : *value = ((Wire.receive() << 8) | Wire.receive());

While it works -now- it's bad design because evaluation order is not guaranteed in c++.
So it could evaluate left->right or right->left depending on compiler brand/version/settings used.

You should split it into 2 lines to force the order :
*value = ((TinyWireM.read() << 8);
*value = | TinyWireM.read());

I once faced that same problem while switching from gcc to intel compiler which evaluates right->left.

@jamesmyatt
Copy link

jamesmyatt commented Jan 8, 2020

@ChristopheLorenz, it might help if you make a pull request.

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

No branches or pull requests

2 participants