https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82756
Bug ID: 82756
Summary: Poor error message from control flow at global scope
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david at doublewise dot net
Target Milestone: ---
If you compile the following code:
while(true) {}
You get the not especially helpful error message:
<source>:1:1: error: expected unqualified-id before 'while'
while(true) {}
^~~~~
This came up for me in the context of calling a macro that wrapped a few
statements in a `do { ... } while(false);` construct, and I spend a fair amount
of time looking for a missing semicolon somewhere before I finally found the
problem. I would have preferred to get a message along the lines of "while
loops not allowed outside of functions" or something else that directly says
the problem from the user's perspective.