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
Fixed shifting a negative signed value in CondFormats/L1TObjects #25428
Conversation
clang warns that shifting a negative signed value is undefined.
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-25428/7486 |
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages: CondFormats/L1TObjects @cmsbuild, @tocheng, @nsmith-, @rekovic, @franzoni, @thomreis, @ggovi, @pohsun, @lpernie can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
The tests are being triggered in jenkins. |
if (idx < -(int)maxabs && idx >= (int)maxabs) edm::LogWarning("ScaleRangeViolation") | ||
<< "L1MuSignedPacking::packedFromIdx: warning value " << idx | ||
<< "exceeds " << Bits << "-bit range !!!"; | ||
return ~(~0 << Bits) & (idx < 0 ? (1 << Bits) + idx : idx); | ||
return ~(std::numeric_limits<unsigned>::max() << Bits) & (idx < 0 ? (1U << Bits) + idx : idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: ~0
is the old way of turning on all the bits of the value. The problem could also have been fixed by changing to ~0U
to explicitly make the constant an unsigned valued. However, using std::numeric_limits
gives the same value but expresses the intent of the code clearly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect ~0U would have worked as well (and preserved the good old C style)
+1 The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic: |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
+1 |
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
clang warns that shifting a negative signed value is undefined.