Repository navigation
Commit b8b27a9
authored
Fix #15117 (MSBuild arithmetic intrinsics: signed overflow UB in Add/Subtract/Multiply) (#8938)
The $([MSBuild]::Add/Subtract/Multiply) intrinsics in
applyMSBuildStaticFunction computed a+b, a-b and a*b directly on long
long operands from the project file, so values like
$([MSBuild]::Add(9223372036854775807, 1)) were signed-overflow UB
(reported by -fsanitize=signed-integer-overflow).
MSBuild evaluates these in .NET's unchecked context, so on overflow the
result wraps. The arithmetic is now done on unsigned long long and cast
back, which gives the same two's complement result without UB.
Divide/Modulo of LLONG_MIN by -1 throw OverflowException in .NET, so
those return the empty string with a debug message, the same as the
existing division-by-zero handling.
Regression tests added to testMSBuildStaticFunctions.1 parent 37a06d2 commit b8b27a9
2 files changed
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
848 | 849 | | |
849 | 850 | | |
850 | 851 | | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
851 | 868 | | |
852 | 869 | | |
853 | 870 | | |
| |||
894 | 911 | | |
895 | 912 | | |
896 | 913 | | |
897 | | - | |
| 914 | + | |
898 | 915 | | |
899 | | - | |
| 916 | + | |
900 | 917 | | |
901 | | - | |
| 918 | + | |
902 | 919 | | |
903 | 920 | | |
904 | 921 | | |
905 | 922 | | |
906 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
907 | 928 | | |
908 | 929 | | |
909 | 930 | | |
910 | 931 | | |
911 | 932 | | |
912 | 933 | | |
913 | 934 | | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
914 | 939 | | |
915 | 940 | | |
916 | 941 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1211 | 1211 | | |
1212 | 1212 | | |
1213 | 1213 | | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1214 | 1222 | | |
1215 | 1223 | | |
1216 | 1224 | | |
| |||
0 commit comments