This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/38762] New: template sees an overload that should not be visible at point of instantiation


I don't see how to include the requested *.i* file with this web page.  So, you
just get the source and compilation stdout.  Here is the program that does what
seems to be the wrong thing:
-----
// Somehow a function overload is visible that should not have been seen at
// the point of instantiation.
// Reproduce bug with:
// % /usr/bin/g++ -v -save-temps -ansi -pedantic -Wall temp1.cpp
// % ./a.out
// int
// The output should be:
// double

#include <iostream>

template<class T> void g(T a) {  h(a); }
void h(double) { std::cout << "double" << std::endl; }

int main(int argc, char* argv[])
{
  g(1);
  return 0;
}

void h(int) { std::cout << "int" << std::endl; }

-----
Here is the stdout from compilation (the same error happens with 4.1.3 also):

Using built-in specs.
Target: x86_64-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-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
 /usr/lib/gcc/x86_64-linux-gnu/4.2.4/cc1plus -E -quiet -v -D_GNU_SOURCE
temp1.cpp -mtune=generic -ansi -pedantic -Wall -fpch-preprocess -o temp1.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.2
 /usr/include/c++/4.2/x86_64-linux-gnu
 /usr/include/c++/4.2/backward
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include
 /usr/include
End of search list.
 /usr/lib/gcc/x86_64-linux-gnu/4.2.4/cc1plus -fpreprocessed temp1.ii -quiet
-dumpbase temp1.cpp -mtune=generic -ansi -auxbase temp1 -pedantic -Wall -ansi
-version -fstack-protector -fstack-protector -o temp1.s
GNU C++ version 4.2.4 (Ubuntu 4.2.4-1ubuntu3) (x86_64-linux-gnu)
        compiled by GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu3).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2328a9860f8ee3842b3eeb9e852e4412
 as --traditional-format -V -Qy -o temp1.o temp1.s
GNU assembler version 2.18.0 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.18.0.20080103
 /usr/lib/gcc/x86_64-linux-gnu/4.2.4/collect2 --eh-frame-hdr -m elf_x86_64
--hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../../../lib/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../../../lib/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.2.4/crtbegin.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.2.4 -L/usr/lib/gcc/x86_64-linux-gnu/4.2.4
-L/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../.. temp1.o
-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-linux-gnu/4.2.4/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../../../lib/crtn.o


-- 
           Summary: template sees an overload that should not be visible at
                    point of instantiation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dougrm at sprynet dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]