History

revert commit b8b6a5fd7b4e8cab8e5a5d01064cf5bf2b5eed95

As it will cause printf("%llu\n", (unsigned long long)1e19); output 9223372036854775808 instead of 10000000000000000000

kbkpbot committed 1 year ago

Commit eef2db71 parent c6afdff3 files · +4 −4Browse files

Unified · Split

3 files
  1. tccgen.c +1 −4
  2. tests/tests2/134_double_to_signed.c +2 −0
  3. tests/tests2/134_double_to_signed.expect +1 −0
tccgen.c+1−4
@@ -3252,10 +3252,7 @@ error: · 3251 unmodified lines
32523252 vtop->c.i = (vtop->c.ld != 0);
32533253 } else {
32543254 if(sf)
3255− /* the range of [int64_t] is enough to hold the integer part of any float value.
3256− Meanwhile, converting negative double to unsigned integer is UB.
3257− So first convert to [int64_t] here. */
3258− vtop->c.i = (int64_t)vtop->c.ld;
3255+ vtop->c.i = vtop->c.ld;
32593256 else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR))
32603257 ;
32613258 else if (sbt & VT_UNSIGNED)
tests/tests2/134_double_to_signed.c+2−0
@@ -7,4 +7,6 @@ int main() { · 6 unmodified lines
77 printf("%d\n", (int)-2147483648.0);
88 d = -2147483648.0;
99 printf("%d\n", (int)d);
10+
11+ printf("%llu\n", (unsigned long long)1e19);
1012 }
tests/tests2/134_double_to_signed.expect+1−0
@@ -2,3 +2,4 @@ · 1 unmodified line
22 -1
33 -2147483648
44 -2147483648
5+10000000000000000000

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t