History

Fix and extend *FCAST test in tcctest.c

Result of float to unsigned integer conversion is undefined if float is negative. This commit take the absolute value of the float before doing the conversion to unsigned integer and add more float to integer conversion test.

Thomas Preud'homme committed 12 years ago

Commit 02d2ca81 parent 17314a11 file · +8 −5Browse files

Unified · Split

tests/tcctest.c+8−5
@@ -1670,7 +1670,7 @@ void prefix ## fcast(type a)\ · 1669 unmodified lines
16701670 double da;\
16711671 LONG_DOUBLE la;\
16721672 int ia;\
1673− long long lla;\
1673+ long long llia;\
16741674 unsigned int ua;\
16751675 unsigned long long llua;\
16761676 type b;\
@@ -1679,18 +1679,21 @@ void prefix ## fcast(type a)\ · 2 unmodified lines
16791679 la = a;\
16801680 printf("ftof: %f %f %Lf\n", fa, da, la);\
16811681 ia = (int)a;\
1682− lla = (long long)a;\
1682+ llia = (long long)a;\
1683+ a = (a >= 0) ? a : -a;\
16831684 ua = (unsigned int)a;\
16841685 llua = (unsigned long long)a;\
1685− printf("ftoi: %d %u\n", ia, ua);\
1686+ printf("ftoi: %d %u %lld %llu\n", ia, ua, llia, llua);\
16861687 ia = -1234;\
16871688 ua = 0x81234500;\
1689+ llia = -0x123456789012345LL;\
1690+ llua = 0xf123456789012345LLU;\
16881691 b = ia;\
16891692 printf("itof: " fmt "\n", b);\
1690− b = lla;\
1691− printf("lltof: " fmt "\n", b);\
16921693 b = ua;\
16931694 printf("utof: " fmt "\n", b);\
1695+ b = llia;\
1696+ printf("lltof: " fmt "\n", b);\
16941697 b = llua;\
16951698 printf("ulltof: " fmt "\n", b);\
16961699 }\

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