https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96468
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c |tree-optimization --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- I see. In that case, I don't think such a warning can be implemented in the front end (as suggested by the choice of the Component) because if signaled were neither atomic nor volatile (and not a function call as in your new example) the only way to determine whether the loop might terminate is by analyzing the potential accesses in the body of the prior block for those to it. Such analysis is beyond what the C front end can handle. For example, in int signaled; void f (double *a) { { for (int i = 0; i != 7; ++i) a[i] = 0; } while (!signaled); including the block in the loop wouldn't make it finite but the front end can't easily determine that. My point is that issuing a warning suggesting the while loop might have been intended to be a do-while would be misleading, as would be suggesting to rewrite the loop as "while (!signaled) { }" This is not a concern if the condition accesses an atomic/volatile object or is a call to a non-const/non-pure function which is readily available in the front end. For others, the warning would need to do quite a bit more work. With that, I'll change the component to tree-optimization where I believe implementing this might be more feasible. So just to be clear, I'm not objecting to the request, just clarifying what it asks for and how difficult it might be implement.