From b1e72eca0caf9bb10d66577573d4845557e61c25 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 27 Jan 2015 19:27:39 +0000 Subject: [PATCH] [libcxx] Make __wrap_iter work with gcc. he following snippet doesn't build when using gcc and libc++: #include void f(const std::string& s) { s.begin(); } #include void AppendTo(const std::vector& v) { v.begin(); } The problem is that __wrap_iter has a private constructor. It lists vector<> and basic_string<> as friends, but gcc seems to ignore this for vector<> for some reason. Declaring vector before the friend declaration in __wrap_iter is enough to work around this problem, so do that. With this patch, I'm able to build chromium/android with libc++. Without it, two translation units fail to build. (iosfwd already provides a forward declaration of basic_string.) As far as I can tell, this is due to a gcc bug, which I filed as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816. Fixes PR22355. http://reviews.llvm.org/D7201 llvm-svn: 227226 --- libcxx/include/iterator | 2 ++ .../iterators.general/gcc_workaround.pass.cpp | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 libcxx/test/std/iterators/iterators.general/gcc_workaround.pass.cpp diff --git a/libcxx/include/iterator b/libcxx/include/iterator index bcf142a..f3e7a8a 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -1112,6 +1112,8 @@ typename enable_if >::type __unwrap_iter(__wrap_iter<_Tp*>); +template class _LIBCPP_TYPE_VIS_ONLY vector; + template class __wrap_iter { diff --git a/libcxx/test/std/iterators/iterators.general/gcc_workaround.pass.cpp b/libcxx/test/std/iterators/iterators.general/gcc_workaround.pass.cpp new file mode 100644 index 0000000..6522bd3 --- /dev/null +++ b/libcxx/test/std/iterators/iterators.general/gcc_workaround.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Tests workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816. + +#include + +void f(const std::string &s) { s.begin(); } + +#include + +void AppendTo(const std::vector &v) { v.begin(); } + +int main() {} -- 2.7.4