This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79175] incorrect visibility of variables in if-else if blocks with dynamic_cast
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 21 Jan 2017 16:19:44 +0000
- Subject: [Bug c++/79175] incorrect visibility of variables in if-else if blocks with dynamic_cast
- Auto-submitted: auto-generated
- References: <bug-79175-4@http.gcc.gnu.org/bugzilla/>
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.