On 11 April 2017 at 08:35, Marshall Clow via Phabricator via cfe-commits < cfe-commits@lists.llvm.org> wrote:
> mclow.lists added a comment. > > Complete reproducer: > > // Tested with with: clang++ -std=c++14 -Wunused-function > UnusedFVassily.cpp > // > // UnusedFVassily.cpp:8:39: warning: unused function '__test' > [-Wunused-function] > // template <class _Up> static __two __test(...); > // ^ > // UnusedFVassily.cpp:9:38: warning: unused function '__test' > [-Wunused-function] > // template <class _Up> static char __test(typename _Up::pointer* = 0); > // ^ > // 2 warnings generated. > > #include <type_traits> > > namespace foo { > > struct __two {char __lx; char __lxx;}; > namespace __has_pointer_type_imp > { > > template <class _Up> static __two __test(...); > template <class _Up> static char __test(typename _Up::pointer* = 0); > > } > > template <class _Tp> > struct __has_pointer_type > > : public std::integral_constant<bool, > sizeof(__has_pointer_type_imp::__test<_Tp>(0)) > == 1> > This is a bug in libc++. If this header is included into two translation units, they will be referencing different __test functions here (because the template has internal linkage due to the 'static'), resulting in an ODR violation. > { > }; > > } > > struct S1 {}; > struct S2 { typedef void *pointer; }; > > int main () { > static_assert (!foo::__has_pointer_type<S1>::value, "" ); > static_assert ( foo::__has_pointer_type<S2>::value, "" ); > } > > > https://reviews.llvm.org/D29877 > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits