Getting action on your favorite D issues

TheGag96 thegag96 at gmail.com
Sat Jun 6 06:37:21 UTC 2020


On Friday, 5 June 2020 at 23:53:28 UTC, H. S. Teoh wrote:
> Nah, it's not silly, it's just that DMD's backend produces code 
> that exhibits quantum uncertainty:

I actually encountered something goofy like this a few weeks ago 
when working on my 3DS homebrew, compiling with LDC. I started 
failing an assert in a game entity's frame logic function that 
checks two numbers for equality that I knew totally should have 
been going through. Right before the assert, I added code that 
looked like this, just to check my sanity:

if (a != b) {
   printf("%d %d %d\n", a, b, a == b);
   foreach (i; 0..10) {
     printf("%d %d %d\n", a, b, a == b);
   }
}

The result was, I kid you not, something like this:

1234 1234 0
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1
1234 1234 1

I was probably hitting UB somewhere... I slap all my entity 
instances together in an array where the element size is the size 
of the biggest entity type, using a union to accomplish that. 
After shifting some code around, it went away, and I haven't seen 
it since. Spooky...!


More information about the Digitalmars-d mailing list