cm0002@lemmy.zip to Programmer Humor@programming.dev · 9 days agoMore code = more betterlemmy.zipimagemessage-square81linkfedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageMore code = more betterlemmy.zipcm0002@lemmy.zip to Programmer Humor@programming.dev · 9 days agomessage-square81linkfedilink
minus-squareDumhuvud@programming.devlinkfedilinkEnglisharrow-up0·9 days agoYou jest, but you aren’t wrong. At least if we are talking about C, C++ or Rust. https://godbolt.org/z/oPPfdfcf5 .NET compiler is weak when it comes to optimizing your code; I assume Go’s is as bad.
minus-squareYggstyle@lemmy.worldlinkfedilinkarrow-up0·9 days agoTechnically yes… But I think he was more making the excuse for the gore “from the goresmith’s perspective.” And I’m not sure if the compiler in any language would change a random check function… The others are a possibility.
minus-squareyetAnotherUser@discuss.tchncs.delinkfedilinkarrow-up0·9 days agoNot sure about the last one though. The other two are trivial to optimize away.
minus-squareHirom@beehaw.orglinkfedilinkarrow-up0·9 days agoAn infinite loop canot be ruled out in the last case, so a compiler couldn’t optimize this away without potentially changing the program behavior.
minus-squareyetAnotherUser@discuss.tchncs.delinkfedilinkarrow-up0·9 days agoInfinite loops are often weird though. They could be seen as undefined behavior and the compiler may do whatever it feels like.
minus-squareronigami@lemmy.worldlinkfedilinkarrow-up0·9 days agoHow could an infinite loop be considered UB?
The compiler will optimize it anyway. /s
You jest, but you aren’t wrong. At least if we are talking about C, C++ or Rust. https://godbolt.org/z/oPPfdfcf5
.NET compiler is weak when it comes to optimizing your code; I assume Go’s is as bad.
Technically yes… But I think he was more making the excuse for the gore “from the goresmith’s perspective.”
And I’m not sure if the compiler in any language would change a random check function… The others are a possibility.
Not sure about the last one though. The other two are trivial to optimize away.
An infinite loop canot be ruled out in the last case, so a compiler couldn’t optimize this away without potentially changing the program behavior.
Infinite loops are often weird though. They could be seen as undefined behavior and the compiler may do whatever it feels like.
How could an infinite loop be considered UB?