5 ms·
That it is Undefined Behavior for a loop with a non-constant conditional and that doesn't cause side effects in its body to not terminate. For example, you can
by gfaster 10mo ago
That it is Undefined Behavior for a loop with a non-constant conditional and that doesn't cause side effects in its body to not terminate.
For example, you can use this make the compiler "prove" the Collatz Conjecture:
https://gcc.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:4,endLineNumber:1,positionColumn:4,positionLineNumber:1,selectionStartColumn:4,selectionStartLineNumber:1,startColumn:4,startLineNumber:1),source:'void+%0Acollatz(long+n)%0A%7B%0A++++while+(n+!!%3D+1)+%7B%0A++++++++if+(n+%25+2+%3D%3D+0)+%7B%0A++++++++++++n+/%3D+2%3B%0A++++++++%7D+else+%7B%0A++++++++++++n+%3D+n+*+3+%2B+1%3B%0A++++++++%7D%0A++++%7D%0A++++return%3B%0A%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:36.16150836001423,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:cclang2110,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,libs:!(),options:'-O3',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+21.1.0+(Editor+%231)',t:'0')),header:(),k:63.838491639985776,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4 https://gcc.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(file...