3 ms·
> The loop must be a trivially empty iteration statement -- meaning its body is literally empty This seems to say that the loop body can not be "continue". In
by omoikane 15d ago
> The loop must be a trivially empty iteration statement -- meaning its body is literally empty
This seems to say that the loop body can not be "continue". Indeed, I just tried -std=c++26 with ";" and got an infinite loop as promised, but "continue" restores the undefined behavior:
- "while(true);" -> https://godbolt.org/z/T65o51crx https://godbolt.org/z/T65o51crx
- "while(true) continue;" -> https://godbolt.org/z/Pj9raEcnP https://godbolt.org/z/Pj9raEcnP
This is unfortunate since I know of one style guide that prefers "continue" over single semicolons. I guess all those code will be doing "while(true) {}" from now on.
https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching:~:text=Empty%20loop%20bodies%20should%20use%20either%20an%20empty%20pair%20of%20braces%20or%20continue%20with%20no%20braces%2C%20rather%20than%20a%20single%20semicolon https://google.github.io/styleguide/cppguide.html#Formatting...