Bug 37728 - if scoping for declarations
Summary: if scoping for declarations
Status: RESOLVED DUPLICATE of bug 18770
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-03 18:10 UTC by Mike Stump
Modified: 2008-10-03 18:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Stump 2008-10-03 18:10:36 UTC
In:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-October/017449.html

we were discussing possible bugs in g++ scoping for if statements.

$ cat t.cc
void foo() {
  if (int x = 0) {
    int x;
  }
}
$ ./xgcc -B./ -c t.cc 
$ 

they expected this to produce a redeclaration error on the inner declaration for X.

Tested on gcc version 4.4.0 20081003 (experimental) [trunk revision 140855] (GCC)

There were other concerns about for, but, others seem to think gcc does the right thing with them.
Comment 1 pinskia@gmail.com 2008-10-03 18:23:47 UTC
Subject: Re:   New: if scoping for declarations



Sent from my iPhone

On Oct 3, 2008, at 11:10 AM, "mrs at apple dot com" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

> In:
>
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-October/017449.html
>
> we were discussing possible bugs in g++ scoping for if statements.
>
> $ cat t.cc
> void foo() {
>  if (int x = 0) {
>    int x;
>  }
> }

This is invalid C++ but it is valid C99. There is already a duplicated  
bug filed for this too but I am too lazy right now to find it.

>
> $ ./xgcc -B./ -c t.cc
> $
>
> they expected this to produce a redeclaration error on the inner  
> declaration
> for X.
>
> Tested on gcc version 4.4.0 20081003 (experimental) [trunk revision  
> 140855]
> (GCC)
>
> There were other concerns about for, but, others seem to think gcc  
> does the
> right thing with them.
>
>
> -- 
>           Summary: if scoping for declarations
>           Product: gcc
>           Version: 4.4.0
>            Status: UNCONFIRMED
>          Severity: normal
>          Priority: P3
>         Component: c++
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: mrs at apple dot com
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37728
>
Comment 2 Andrew Pinski 2008-10-03 18:46:04 UTC

*** This bug has been marked as a duplicate of 18770 ***