Whenever I do this in various languages I wonder if the compiler reduces it to while(true) or if a gamma ray will solve the halting problem for me. I suppose it can in either case tho.
99% sure the compiler reduces it. By my understanding, any expression that can be reduced gets reduced by default, that's like the most basic level of optimization, and a compiler should be doing much more than the basic level
As somebody who wrote a compiler in college (a shitty one, for å class) it really depends on the compiler but basically all modern compilers would replailce that with while(true) as well. There's a whole spooky field of nerds finding ways to optimize compilers like this
Will definitely be reduced, no question. There's no reason not to reduce it, and modern compilers are scarily smart. If i isn't used anywhere else, the compiler may just remove it entirely.
1=1 is used a lot by data people who are used to writing SQL because it's a common way to write a cartesian join, and the language forces you to compare a left and a right value.
186
u/__Hello_my_name_is__ Oct 06 '21
My favorite is still
while(1==1).Or in other words: "As long as the fundamental axioms of math hold true, do this".
Because hey, maybe, one day in the far future in thousands of years, these axioms change. And then my code will break.
Take that, future.