SpacemanDMM icon indicating copy to clipboard operation
SpacemanDMM copied to clipboard

constant folding still has some issues regarding overflows

Open willox opened this issue 3 years ago • 1 comments

related: https://github.com/SpaceManiac/SpacemanDMM/commit/90d81ddbf74c6c637e9224f056eb2256f3eed6a8

Code:

#define TEST 2147483647 + 1 + 1073741824 + 1073741824

#if TEST
/world/New()
	world.log << "Good"
#else
"poop"
#endif

Release builds of DreamChecker evaluates TEST to 0 when it should be 4294967296, and so hits a compile error. Debug builds will just panic thanks to rust, so it's pretty easy to test for.

My first instinct is that this could be solved by using float arithmetic for all constant folding and then converting back to integers if desired.

willox avatar Mar 02 '21 21:03 willox

My first instinct is that this could be solved by using float arithmetic for all constant folding and then converting back to integers if desired.

Ultimately having a Constant::Int separate from Constant::Float does not reflect the reality of DM, so it should be eliminated.

SpaceManiac avatar May 18 '21 06:05 SpaceManiac

I think this was fixed in ce0345efc07d082108b712b283c73bd909895a7b

SpaceManiac avatar Jun 25 '24 01:06 SpaceManiac