Skip to content

Evaluation order is not guaranteed #2

Description

@ChristopheLorenz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions