https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79175
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |msebor at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
In a selection statement like the if statement, the "name introduced by a
declaration in a condition [...] is in scope from its point of declaration
until the end of the substatements controlled by the condition." So for
example, in
if (int x = f()) {
int x;
}
else {
int x;
}
the declarations of x in both substatements of the if statement are il-formed
because they attempt to redeclare the x declared in the condition of the if
statement.
Thus the submitted program is valid and GCC is correct in accepting it.