On Fri, Oct 04, 2019 at 11:52:11AM +0000, Bernd Edlinger wrote: > Admittedly I was also completely surprised that the if scope > extends to the else block. If that is in fact wrong, we ought to > fix that before I ruin the while code-base with changes like that.
It is correct. http://eel.is/c++draft/stmt.stmt [stmt.stmt]/5 says: "A name introduced in a selection-statement or iteration-statement outside of any substatement is in scope from its point of declaration until the end of the statement's substatements. Such a name cannot be redeclared in the outermost block of any of the substatements." if with else has 2 substatements and the condition declaration is in scope in both of them. Jakub