From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5828 invoked by alias); 14 Sep 2005 18:54:56 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 4507 invoked by uid 48); 14 Sep 2005 18:54:16 -0000 Date: Wed, 14 Sep 2005 18:54:00 -0000 From: "martin dot audet at imi dot cnrc-nrc dot gc dot ca" To: gcc-bugs@gcc.gnu.org Message-ID: <20050914185413.23885.martin.audet@imi.cnrc-nrc.gc.ca> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/23885] New: incorrect template two-stage name-lookup X-Bugzilla-Reason: CC X-SW-Source: 2005-09/txt/msg01752.txt.bz2 List-Id: It looks like the two stage name binding doesn't work for the following small program. This happen with many g++ versions (including recent ones) except version 3.3.2 Red Hat: Config `g++ --version` result 1- 2.96 20000731 (Red Hat Linux 7.1 2.96-81) wrong 2- 3.2.3 wrong 3- 3.3.2 20031022 (Red Hat Linux 3.3.2-1) right 4- 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) wrong 5- 3.4.3 wrong 6- 4.0.0 20041019 (Red Hat 4.0.0-0.8) wrong 7- 4.0.1 20050727 (Red Hat 4.0.1-5) wrong All of these configurations run Linux (i686 kernels except the last one which run in 64 bits mode x86_64). Here is the small program: template int g(T a) { return h(a); // "h" is a dependent name. // Binding will occurs at instantiation. } // "h" in g() should be bound to this function even // if "h" is overloded later with a "more natural" version. int h(double) { return 0; } // Instantiation point for g(). int i(void) { extern int h(int); // Should not influence the choice of the "h" function // because it is out of scope at instantiation point. // Note: The problem occur even if this declaration is // commented out. return g(234); // g(234) is called. } // "h" in g() should not be bound to this version of // "h" function even if it is "more natural". This is because // its declaration occurs after instatiation point. int h(int) { return 1; } int main(void) { // Should return 0. return i(); } Configurations Details: Config 1 (Red Hat Linux 7.1, pentium III) /usr/bin/g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) Config 2 (Red Hat Linux 7.1, manual gcc installation, pentium III) g++ -v Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs Configured with: /home/publique/download/gcc-3.2.3/configure --enable-__cxa_atexit Thread model: posix gcc version 3.2.3 Config 3 (Updated Fedora Core 1 Linux, pentium III) /usr/bin/g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system -zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1) Config 4 (Fedora Core 3 Linux, pentium 4) g++ -v Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system -zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) Config 5 (Updated Fedora Core 1 Linux, manual gcc installation, pentium III) g++ -v Reading specs from /home/publique/newer_gcc/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/specs Configured with: ../gcc-3.4.3/configure --prefix=/usr/local/newer_gcc --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.4.3 Config 6 (Fedora Core 3 Linux, pentium 4) g++4 -v Reading specs from /usr/lib/gcc/i386-redhat-linux/4.0.0/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --with-gxx-include-dir=/usr/include/c++/3.4.2 --enable-languages=c,c++,f95 --disable-libgcj --host=i386-redhat-linux Thread model: posix gcc version 4.0.0 20041019 (Red Hat 4.0.0-0.8) Config 7 (Updated Fedora Core 4 Linux, pentium 4 Xeon, 64 bit mode) g++ -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=x86_64-redhat-linux Thread model: posix gcc version 4.0.1 20050727 (Red Hat 4.0.1-5) Martin Audet E: martin.audet@nrc.ca T: 450-641-5034 Research Officer Industrial Material Institute / National Research Council 75 de Mortagne, Boucherville, QC J4B 6Y4, Canada -- Summary: incorrect template two-stage name-lookup Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: martin dot audet at imi dot cnrc-nrc dot gc dot ca CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: i386-redhat-linux and x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23885