From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10324 invoked by alias); 3 Feb 2015 19:30:01 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10289 invoked by uid 48); 3 Feb 2015 19:29:57 -0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64926] Variable declared in if-statement-header is in wrong scope Date: Tue, 03 Feb 2015 19:30:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: accepts-invalid, diagnostic X-Bugzilla-Severity: critical X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg00249.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64926 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski --- No GCC is correct, the scope of the variable x is for both the true part and the false part of the if statement. You can't declare another variable with the name of x in either part though but in your case we have a single statement of if(true) {..} which means you can declare another variable of the same name in the {} part as it is an inner-scope.