Created attachment 36460 [details] Module.ii.bz2 Version of GCC: Using built-in specs. COLLECT_GCC=/usr/local/bin/x86_64-portbld-freebsd11.0-g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-portbld-freebsd11.0/4.9.2/lto-wrapper Target: x86_64-portbld-freebsd11.0 Configured with: ./../gcc-4.9.2/configure --target=x86_64-portbld-freebsd11.0 --disable-nls --enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-pkgversion='FreeBSD Ports Collection for amd64' --with-system-zlib --with-as=/usr/local/bin/x86_64-freebsd-as --with-ld=/usr/local/bin/x86_64-freebsd-ld --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=x86_64-portbld-freebsd11.0 Thread model: posix gcc version 4.9.2 (FreeBSD Ports Collection for amd64) System: FreeBSD 11.0-CURRENT #6 r286639 Problem Description: When clang 3.7.0 is compiled with gcc 4.9.2, using this command: /usr/local/bin/x86_64-portbld-freebsd11.0-g++ -save-temps -isystem /usr/obj/opt2/branches/head/tmp/usr/include -L/usr/obj/opt2/branches/head/tmp/usr/lib --sysroot=/usr/obj/opt2/branches/head/tmp -B/usr/local/x86_64-freebsd/bin/ -I/usr/obj/opt2/branches/head/tmp/usr/include/c++/v1 -std=gnu++11 -L/usr/obj/opt2/branches/head/tmp/../lib/libc++ --sysroot=/usr/obj/opt2/branches/head/tmp -B/usr/local/x86_64-freebsd/bin/ -O2 -pipe -I/opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/include -I/opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/tools/clang/include -I/opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/tools/clang/lib/Basic -I. -I/opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/../../lib/clang/include -DLLVM_ON_UNIX -DLLVM_ON_FREEBSD -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_STATIC_ANALYZER -fno-strict-aliasing -DLLVM_DEFAULT_TARGET_TRIPLE=\"x86_64-unknown-freebsd11.0\" -DLLVM_HOST_TRIPLE=\"x86_64-unknown-freebsd11.0\" -DDEFAULT_SYSROOT=\"\" -fstack-protector-strong -std=c++11 -fno-exceptions -fno-rtti -c /opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/tools/clang/lib/Basic/Module.cpp -o Module.o the following error is observed: In file included from /opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/tools/clang/include/clang/Basic/SourceLocation.h:22:0, from /opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/tools/clang/include/clang/Basic/Module.h:18, from /opt2/branches/head/lib/clang/libclangbasic/../../../contrib/llvm/tools/clang/lib/Basic/Module.cpp:15: /usr/obj/opt2/branches/head/tmp/usr/include/c++/v1/functional:1322:17: error: '_Rp std::__1::__function::__base<_Rp(_ArgTypes ...)>::operator()(_ArgTypes&& ...) [with _Rp = void; _ArgTypes = {clang::VisibleModuleSet::setVisible(clang::Module*, clang::SourceLocation, clang::VisibleModuleSet::VisibleCallback, clang::VisibleModuleSet::ConflictCallback)::Visiting}]', declared using local type 'clang::VisibleModuleSet::setVisible(clang::Module*, clang::SourceLocation, clang::VisibleModuleSet::VisibleCallback, clang::VisibleModuleSet::ConflictCallback)::Visiting', is used but never defined [-fpermissive] virtual _Rp operator()(_ArgTypes&& ...) = 0;
I was able to work around this problem in two ways, as I mentioned on the cfe-dev mailing list for LLVM: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045336.html (1) Patch Module.cpp to move "struct Visitor" outside of VisibleModuleSet::setVisible() OR (2) Add -fpermissive to command-line clang can compile this with no problem, so I am filing the bug here.
Why do you use LLVM's libc++? This is not supported in any way. So please use gcc's libstdc++ instead.
This is for cross-compiling the FreeBSD base system with GCC. The FreeBSD base system has libc++, which was recently upgraded to clang 3.7.0. Cross-compiling FreeBSD base system with GCC worked before, with an older version of libc++. Discussion on the llvm cfe-dev mailing list seems to point to this being a bug in GCC, hence I filed this bug.
Reduced: namespace std { template <class _Tp> struct remove_reference {typedef _Tp type;}; template <class _Tp> struct remove_reference<_Tp&> {typedef _Tp type;}; template <class _Tp> struct remove_reference<_Tp&&> {typedef _Tp type;}; template <class _Tp> inline _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) throw() { return static_cast<_Tp&&>(__t); } template <class _Tp> inline _Tp&& forward(typename std::remove_reference<_Tp>::type&& __t) throw() { return static_cast<_Tp&&>(__t); } template<class _Fp> class function; namespace __function { template<class _Fp> class __base; template<class _Rp, class ..._ArgTypes> class __base<_Rp(_ArgTypes...)> { public: virtual _Rp operator()(_ArgTypes&& ...) = 0; }; template<class _FD, class _Alloc, class _FB> class __func; template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { public: virtual _Rp operator()(_ArgTypes&& ... __arg); }; template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) { return {}; } } template<class _Rp, class ..._ArgTypes> class function<_Rp(_ArgTypes...)> { typedef __function::__base<_Rp(_ArgTypes...)> __base; __base* __f_; public: template<class _Fp> function(_Fp); _Rp operator()(_ArgTypes...) const; }; template<class _Rp, class ..._ArgTypes> template <class _Fp> function<_Rp(_ArgTypes...)>::function(_Fp) : __f_(0) { } template<class _Rp, class ..._ArgTypes> _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { return (*__f_)(std::forward<_ArgTypes>(__arg)...); } } void setVisible() { struct Visiting { }; std::function<void(Visiting)> VisitModule { [&](Visiting) { } }; VisitModule({}); } Fails with 4.9 and 5.2: mod.ii:34:17: error: ‘_Rp std::__function::__base<_Rp(_ArgTypes ...)>::operator()(_ArgTypes&& ...) [with _Rp = void; _ArgTypes = {setVisible()::Visiting}]’, declared using local type ‘setVisible()::Visiting’, is used but never defined [-fpermissive] virtual _Rp operator()(_ArgTypes&& ...) = 0; ^ Compiles OK with trunk.
I don't know what fixed it, or if it's worth backporting.
This appears to have been fixed with https://gcc.gnu.org/viewcvs?rev=224492&root=gcc&view=rev by Paolo Carlini, see also bug 51048. It seems to look easy enough to backport to earlier branchs. Paolo, can you please confirm?
I have no objections, the patch seems safe to backport. Jason, shall I go ahead if it regtests Ok on the branch?
(In reply to Paolo Carlini from comment #7) > I have no objections, the patch seems safe to backport. Jason, shall I go > ahead if it regtests Ok on the branch? Sure.
Done. I'm resolving this one as Dup of c++/51048. *** This bug has been marked as a duplicate of bug 51048 ***