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

Don't rely on unsequenced evaluation order in bintool/metadata.h (#187) #188

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

ericm1024
Copy link

With the following compiler:
% /Library/Developer/CommandLineTools/usr/bin/c++ --version Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I was getting the following warning:

metadata.h:258:44: warning: multiple unsequenced modifications to 'i' [-Wunsequenced]

It appears as though the code relies on the leftmost i++ happening first, followed by the rightmost, but the language seemingly provides no such guarantee.

Fix this by reading the low and high words in order, then combining them, rather than doing so in a single expression.

…pberrypi#187)

With the following compiler:
% /Library/Developer/CommandLineTools/usr/bin/c++ --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I was getting the following warning:

metadata.h:258:44: warning: multiple unsequenced modifications to 'i' [-Wunsequenced]

It appears as though the code relies on the leftmost i++ happening first,
followed by the rightmost, but the language seemingly provides no such
guarantee.

Fix this by reading the low and high words in order, then combining them,
rather than doing so in a single expression.
@lurch
Copy link
Contributor

lurch commented Dec 8, 2024

Oh, and can you change the base branch to develop please, instead of master?

@ericm1024 ericm1024 changed the base branch from master to develop December 10, 2024 02:49
@will-v-pi will-v-pi merged commit a672c24 into raspberrypi:develop Dec 10, 2024
32 checks passed
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 this pull request may close these issues.

3 participants