From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10636 invoked by alias); 3 Jul 2008 02:03:07 -0000 Received: (qmail 6855 invoked by uid 48); 3 Jul 2008 02:02:22 -0000 Date: Thu, 03 Jul 2008 02:03:00 -0000 Subject: [Bug c++/36709] New: Compiler allows namespace and class to have same name and doesn't generate ambiguous reference error when it should result from this. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rquabili at princeton dot edu" 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: 2008-07/txt/msg00146.txt.bz2 Since J is already defined, the namespace declaration should generate an error ("int J; namespace J{}" does generate an error). G++ gets confused with the g() call and instead of generating an error it passes the problem to the assembler. main.cpp: struct J { static void g() {} }; namespace J { void g() {} } int main() { J::g(); return 0; } Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) $ gcc main.cpp /tmp/ccgibTUW.s: Assembler messages: /tmp/ccgibTUW.s:25: Error: symbol `_ZN1J1gEs' is already defined -- Summary: Compiler allows namespace and class to have same name and doesn't generate ambiguous reference error when it should result from this. Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rquabili at princeton dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36709