https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96468
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- It's not clear whether the request is just for the specific case for while loops with a volatile control variable or independent of the qualifier. I think issuing a warning in either case would be worthwhile but for different reasons, and with different messages making a distinction between the kinds of the potential problems. (The mention of the suggestion to use "while(condition){}" instead makes me think it might be the former.) Thanks to the volatile access in the example in comment #0, the loop will terminate once signaled is set but the intent may have been that it iterate over the body of the preceding block. signaled can be set either in one of the calls in the block in some signal handler, or even in another thread (in addition to being set prior to the block of course). But in the absence of the volatile (and atomic) qualifier, unless the initial value of signaled is non-zero the loop will never terminate regardless of any extraneous accesses to it outside it because all but the first access to it in the loop is eliminated: int signaled; void f (void) { while (!signaled); }