From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21052 invoked by alias); 23 Sep 2007 18:09:22 -0000 Received: (qmail 20976 invoked by uid 48); 23 Sep 2007 18:09:11 -0000 Date: Sun, 23 Sep 2007 18:09:00 -0000 Message-ID: <20070923180911.20975.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/33518] unused code changes the result of name lookup In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "bangerth at dealii dot org" 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 X-SW-Source: 2007-09/txt/msg01943.txt.bz2 ------- Comment #2 from bangerth at dealii dot org 2007-09-23 18:09 ------- This indeed looks like a bug. Take this: --------------------- #include namespace M { struct A {}; using std::distance; } namespace N { template struct S {}; class Q : S {}; int distance(Q,Q); } int i = distance (N::Q(), N::Q()); ---------------- I would expect this to compile: all arguments to the call to distance() have associated namespace N, so we would expect that the compiler finds N::distance. However, apparently, gcc also performs the derived-to-base conversion to find S and concludes that namespace M is also associated from where it tries to use std::distance and gives the error g/x> c++ -c y.cc /usr/include/c++/4.1.2/bits/stl_iterator_base_types.h: In instantiation of 'std::iterator_traits': y.cc:15: instantiated from here /usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:129: error: no type named 'iterator_category' in 'class N::Q' /usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:130: error: no type named 'value_type' in 'class N::Q' /usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:131: error: no type named 'difference_type' in 'class N::Q' /usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:132: error: no type named 'pointer' in 'class N::Q' /usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:133: error: no type named 'reference' in 'class N::Q' It shouldn't be hard to produce a wrong-code bug from this. If someone wants to beat me to producing something without the include file, feel free... W. -- bangerth at dealii dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2007-09-23 18:09:10 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33518