There's no guarantee that it will remove it, that's going to be compiler and flag dependent, but by spec it is a legal optimization.
If you do have a need for the spin loop, I'm assuming every compiler will have some flag that allows you to skip optimization on removing spin loops. But again, I'm not sure there really is any reason to have a hard spin loop outside of malware
View all comments
Show parent comment
1
u/Cruuncher Oct 19 '26
There's no guarantee that it will remove it, that's going to be compiler and flag dependent, but by spec it is a legal optimization.
If you do have a need for the spin loop, I'm assuming every compiler will have some flag that allows you to skip optimization on removing spin loops. But again, I'm not sure there really is any reason to have a hard spin loop outside of malware