test/fpcnv: skip of inexactly converted integers
In C, if a floating point cannot be represented exactly as an integer, conversion from the former to the latter is implementation-defined. Therefore, it can be flaky to test this against QBE-defined behavior. This was discovered from (unsigned int) 4294967295.0f being an UB, because (uint64_t) 4294967295.0f is 4294967296 > UINT_MAX on amd64 when compiled by either gcc or clang.
This commit is contained in:
parent
b582e84e10
commit
be5d46fe7d
1 changed files with 10 additions and 5 deletions
|
@ -72,6 +72,7 @@ function l $dtol(d %f) {
|
||||||
|
|
||||||
|
|
||||||
# >>> driver
|
# >>> driver
|
||||||
|
# #include <float.h>
|
||||||
# #include <limits.h>
|
# #include <limits.h>
|
||||||
#
|
#
|
||||||
# extern float fneg(float);
|
# extern float fneg(float);
|
||||||
|
@ -113,15 +114,19 @@ function l $dtol(d %f) {
|
||||||
# return 7;
|
# return 7;
|
||||||
# }
|
# }
|
||||||
# for (i=0; i<sizeof(fin)/sizeof(fin[0]); i++) {
|
# for (i=0; i<sizeof(fin)/sizeof(fin[0]); i++) {
|
||||||
# if (stol((float)fin[i]) != (unsigned long long)(float)fin[i])
|
# if (fin[i] >= 1LL << DBL_MANT_DIG)
|
||||||
# return 8;
|
# break;
|
||||||
# if (dtol(fin[i]) != (unsigned long long)fin[i])
|
# if (dtol(fin[i]) != (unsigned long long)fin[i])
|
||||||
# return 9;
|
# return 8;
|
||||||
# if((unsigned long long)fin[i] > UINT_MAX)
|
# if((unsigned long long)fin[i] > UINT_MAX)
|
||||||
# continue;
|
# continue;
|
||||||
# if (stow((float)fin[i]) != (unsigned int)(float)fin[i])
|
|
||||||
# return 10;
|
|
||||||
# if (dtow(fin[i]) != (unsigned int)fin[i])
|
# if (dtow(fin[i]) != (unsigned int)fin[i])
|
||||||
|
# return 9;
|
||||||
|
# if (fin[i] >= 1LL << FLT_MANT_DIG)
|
||||||
|
# continue;
|
||||||
|
# if (stol((float)fin[i]) != (unsigned long long)(float)fin[i])
|
||||||
|
# return 10;
|
||||||
|
# if (stow((float)fin[i]) != (unsigned int)(float)fin[i])
|
||||||
# return 11;
|
# return 11;
|
||||||
# }
|
# }
|
||||||
# return 0;
|
# return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue