This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/79175] incorrect visibility of variables in if-else if blocks with dynamic_cast


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]