[gamecode] Mention possibly undefined behavior

It seems casting from float/double to [unsigned] int/long when the value
doesn't fit is undefined (which would explain the inconsistent results).
Mentioning the possibility seems like a good idea should the results for
such casts change and cause the tests to fail.
This commit is contained in:
Bill Currie 2022-01-14 16:52:44 +09:00
parent a1c1c9fcf0
commit a81067603c
4 changed files with 8 additions and 10 deletions

View file

@ -39,9 +39,9 @@ static pr_ivec4_t int_conv_expect[] = {
{ ~0, ~0, ~0, 0}, //bool64
{ 0, ~0, 0, 0}, //bool64
{ 0, 0, 0, 0}, // int
{ 1, -1, 0x80000000, 0x80000000}, // float
{ 1, -1, 0x80000000, 0x80000000}, // float undef?
{ 99, 0x80000000, 256, 0x7fffffff}, // long
{ 0x80000000, 0x80000000, 1, -1}, // double
{ 0x80000000, 0x80000000, 1, -1}, // double undef?
{ 0, 0, 0, 0}, // uint
{ 1, 1, 1, 0}, // bool32
{ 99, 0x80000000, 256, 0x7fffffff}, // ulong

View file

@ -49,10 +49,10 @@ static pr_ivec4_t long_conv_expect[] = {
{ 5, 0, -5, 0xffffffff}, // int
{ 0x80000000, 0xffffffff, 0x7fffffff, 0},
{ 1, 0, -1, -1}, // float
{ 0, 0x80000000, 0, 0x80000000},
{ 0, 0x80000000, 0, 0x80000000}, // undef?
{ 0, 0, 0, 0}, // long
{ 0, 0, 0, 0},
{ 0, 0x80000000, 0, 0x80000000}, // double
{ 0, 0x80000000, 0, 0x80000000}, // double undef?
{ 1, 0, -1, -1},
{ 5, 0, -5, 0}, // uint
{ 0x80000000, 0, 0x7fffffff, 0},

View file

@ -39,11 +39,9 @@ static pr_ivec4_t uint_conv_expect[] = {
{ ~0, ~0, ~0, 0}, //bool64
{ 0, ~0, 0, 0}, //bool64
{ 0, 0, 0, 0}, // int
// why 0? expected 0xfffffff. vv gcc bug?
{ 1, 0xffffffff, 0, 0}, // float
{ 1, 0xffffffff, 0, 0}, // float undef?
{ 99, 0x80000000, 256, 0x7fffffff}, // long
// why 0? vv expected 0xfffffff. gcc bug?
{ 0, 0, 1, 0xffffffff}, // double
{ 0, 0, 1, 0xffffffff}, // double undef?
{ 0, 0, 0, 0}, // uint
{ 1, 1, 1, 0}, // bool32
{ 99, 0x80000000, 256, 0x7fffffff}, // ulong

View file

@ -49,10 +49,10 @@ static pr_ivec4_t ulong_conv_expect[] = {
{ 5, 0, -5, 0xffffffff}, // int
{ 0x80000000, 0xffffffff, 0x7fffffff, 0},
{ 1, 0, -1, -1}, // float
{ 0, 0, 0, 0x80000000},
{ 0, 0, 0, 0x80000000}, // undef?
{ 0, 0, 0, 0}, // long
{ 0, 0, 0, 0},
{ 0, 0, 0, 0x80000000}, // double
{ 0, 0, 0, 0x80000000}, // double undef?
{ 1, 0, -1, -1},
{ 5, 0, -5, 0}, // uint
{ 0x80000000, 0, 0x7fffffff, 0},