http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49044
Summary: [C++0x] mangling overload in decltype Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: len...@yahoo.com.cn Created attachment 24283 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24283 preprocessed file of tmpl_decl2.cpp the source code is shown as below: ========================================================================== template<typename T> class W{ protected: T* p; public: W() { p=new T(); } ~W() { if(p) delete p; } auto test1(int i) -> decltype(p->get(i)) { return p->get(i); } template<typename Ta>int test2(Ta&& i) { return p->get(i); } #if 1 // bug in g++ 4.4, 4.5 & 4.6 #define TESTCASE3 template<typename Ta>auto test3(Ta&& i) -> decltype(((T*)0)->get(i)) { return p->get(i); } #endif }; class A; typedef W<A> B; class A{ protected: int _i; public: A():_i(0) {} int get(int i)const { return _i-i; } int get()const { return _i; } }; int main() { int s; B b; s=b.test1(0); s+=b.test2(0); #ifdef TESTCASE3 s+=b.test3(0); #endif return s; } ========================================================================== This bug is closely realted to the bug 49042. In this bug, TESTCASE3 is the same as the TESTCASE4 in bug 49042. While g++ 4.6 can handle TESTCASE4 in bug 49042, it can not handle in this bug, just because there is two get() in class A. In fact, test2() also involves overloaded A::get() and g++ 4.6 can handle it successfully. However, test3() uses A::get() in decltype and g++ 4.6 rejects it with an error message "sorry, unimplemented: mangling overload". I have checked other "mangling overload" reports in this bugzilla, and I don't find any other cases which gives similar situation. btw, g++ 4.4, 4.5 both reject test3() with other error messages, so this is not a regression error. output of "g++ -v -save-temps -std=c++0x -c tmpl_decl2.cpp" ========================================================================== Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.6.0-3~ppa1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/x86_64-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.1 20110409 (prerelease) (Ubuntu 4.6.0-3~ppa1) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/cc1plus -E -quiet -v -D_GNU_SOURCE tmpl_decl2.cpp -mtune=generic -march=x86-64 -std=c++0x -fpch-preprocess -fstack-protector -o tmpl_decl2.ii ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/../../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.6 /usr/include/c++/4.6/x86_64-linux-gnu /usr/include/c++/4.6/backward /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/include /usr/local/include /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/cc1plus -fpreprocessed tmpl_decl2.ii -quiet -dumpbase tmpl_decl2.cpp -mtune=generic -march=x86-64 -auxbase tmpl_decl2 -std=c++0x -version -fstack-protector -o tmpl_decl2.s GNU C++ (Ubuntu 4.6.0-3~ppa1) version 4.6.1 20110409 (prerelease) (x86_64-linux-gnu) compiled by GNU C version 4.6.1 20110409 (prerelease), GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9 GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=62982 GNU C++ (Ubuntu 4.6.0-3~ppa1) version 4.6.1 20110409 (prerelease) (x86_64-linux-gnu) compiled by GNU C version 4.6.1 20110409 (prerelease), GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9 GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=62982 Compiler executable checksum: 9b2d061a0b3f0ab5a4eef825b71a3b00 tmpl_decl2.cpp: In instantiation of ‘decltype ((T*)(0)->.get(i)) W<T>::test3(Ta&&) [with Ta = int, T = A, decltype ((T*)(0)->.get(i)) = int]’: tmpl_decl2.cpp:67:14: instantiated from here tmpl_decl2.cpp:29:28: sorry, unimplemented: mangling overload ==========================================================================