History

(bug caused by tcc intristics) reproduce bug: $ ./configure --cc=gcc $ make $ make install (OK) run a test:

extern int printf(const char *str, ...); int main() { int t2 = (int)(-1.847759065f * 4096); printf("%d\n", t2); } $ tcc test.c $ ./a.out $ -7568 (OK) (self compiled now) $ ./configure --cc=tcc $ make $ make install (OK) $ tcc test.c $ ./a.out $ 7568 (WRONG!!!) why: gcc does not have intristics for uint to long double conversion therefore it does cast implicitly, so the sign bit is preserved, but this does not happen when __fixunsxfdi is called because tcc was bootstrapped. solution: force cast to int64 and preserve the sign bit. side effects: not found.

Kyryl Melekhin committed 6 years ago

Commit 310e3b41 parent 55f89631 file · +1 −1Browse files

Unified · Split

tccgen.c+1−1
@@ -3478,7 +3478,7 @@ again: · 3477 unmodified lines
34783478 vtop->c.i = (vtop->c.ld != 0);
34793479 } else {
34803480 if(sf)
3481− vtop->c.i = vtop->c.ld;
3481+ vtop->c.i = (int64_t)vtop->c.ld;
34823482 else if (sbt_bt == VT_LLONG || (PTR_SIZE == 8 && sbt == VT_PTR))
34833483 ;
34843484 else if (sbt & VT_UNSIGNED)

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