help-rcs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug c++/14515] New: bad interaction between using namespace and for loo


From: christopher dot eltschka at physik dot uni-regensburg dot de
Subject: [Bug c++/14515] New: bad interaction between using namespace and for loop variable
Date: 10 Mar 2004 16:36:43 -0000

The following code gives an error when compiled without any options:

$ g++ bug.cc
bug.cc: In function `int main()':
bug.cc:14: error: name lookup of `i' changed for new ISO `for' scoping
bug.cc:8: error:   using obsolete binding at `i'

The preprocessed code:

# 1 "bug.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.cc"
namespace foo
{
  int i;
}

int main()
{
  for (int i=0; i<=10; ++i)
  {
  }

  {
    using namespace foo;
    i = 5;
  }
}

Since at the point of assignment, there is an accessible i (namely foo::i), it
should be used instead of trying to access the for loop variable (which isn't in
scope any more, as the error message correctly points out).

Configured with: ./configure --prefix=/psi/gcc-3.3

-- 
           Summary: bad interaction between using namespace and for loop
                    variable
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christopher dot eltschka at physik dot uni-regensburg
                    dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14515




reply via email to

[Prev in Thread] Current Thread [Next in Thread]