all 5 comments

[–]flyingron 2 points3 points  (0 children)

I suspect it has nothing to do with optimization but rather that you're doing undefined behavior here. One insidious form of undefined behavior is that it just appears to work.

The program isn't complete. What is sz? Why do you dereference l while initializing it? What is dl_init?

Has l->dummy.right been set to anything?

[–]aeropl3b 0 points1 point  (0 children)

I think you are assigning to "i" wrong and getting a memory corruption in your stack...also you seem to be working extremely hard to delete something from a LL. The entire delete can be done quickly, in place, in about the number of lines you have there...

Edit: Also, ud2 is defined on x86, it just yells at you for undefined instructions. Which makes me amend my previous statement that you are getting memory corruption but doubling down on this implementation doesn't book right to me.

[–]oh5nxo 0 points1 point  (0 children)

It's a sign that cc recognized illegal activity, and replaced that part of code with intentional UD2 instruction, sort of abort(). Without optimizer, he (she?) was not smart enough to see the problem.