Repository navigation
Conversation
|
There should probably be a trac ticket for this PR. Please create it, or ask us to create it. Then the PR title should be updated. |
|
Test results for commit d5402d8 (tools/test-my-pr.py, main compared to this PR): Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-8950/ Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong. |
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no new problems. The range check in fmtDouble is correct: [LLONG_MIN, 2^63) is exactly the set of doubles that convert to long long without undefined behaviour, and NaN fails the check, so it falls through to std::to_string. Round now does its banker's rounding in double, so it no longer casts at all. Its in-range results match the old code, including the negative half cases, -0.5 → 0 and values next to 2^52. LLONG_MIN is already used elsewhere in this file, so the change adds no new include dependency.
Testing
-
I built
cppcheckandtestrunnerinpr/withmake -j8, and both built cleanly. -
./testrunner TestImportProject: 0 failures, including the new asserts forRound,PowandFloor. -
I copied the new
fmtDoubleandRoundlogic intoscratch/t.cppand built it withg++ -fsanitize=undefined,float-cast-overflow -fno-sanitize-recover=all. I ran it on these inputs:- the values around ±2^63 (
9223372036854775807,9223372036854775808,-9223372036854775808,-9223372036854775809),-9.3e18and1e300 nan,inf,-infand-0.0- the half cases
±0.5,±1.5,-2.5and±4503599627370495.5 0.49999999999999994
UBSan reported nothing. All results were what I expected: integer text inside the range,
std::to_stringtext outside it, and round-half-to-even for the half cases. - the values around ±2^63 (
-
I did not repeat the
cppcheck --projectrun on a crafted vcxproj that the description mentions.
Automated review of d5402d8 by Claude. The pull request was built and tested locally.
fmtDouble and the Round branch in ImportProject::applyMSBuildStaticFunction cast the double result of a System.Math property function to long long without a range check, so a project value like
$([System.Math]::Pow(10,30))or$([System.Math]::Round(1e30))is undefined behaviour (UBSan float-cast-overflow, as noted in the AI review on #8938). fmtDouble now takes the integer path only when the value fits in long long, and Round does its half-to-even step in double and formats through fmtDouble, so in-range results are unchanged and Round(1e30) gives the same text as Pow(10,30) instead of LLONG_MIN (out-of-range values still print via std::to_string rather than MSBuild's1E+30, which is left for a separate change). Tested with new asserts in testMSBuildStaticFunctions, the full testrunner, andcppcheck --projecton a crafted vcxproj with a UBSan build. I don't have Trac access, so could you create a ticket for this one?