[PATCH] Make __wrap_iter work with gcc
Nico Weber
thakis at chromium.org
Tue Jan 27 09:54:18 PST 2015
Hi danalbert,
The following snippet doesn't build when using gcc and libc++:
```
#include <string>
void f(const std::string& s) { s.begin(); }
#include <vector>
void AppendTo(const std::vector<char>& 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.
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
Files:
include/iterator
test/std/iterators/iterators.general/gcc_workaround.pass.cpp
Index: include/iterator
===================================================================
--- include/iterator
+++ include/iterator
@@ -1112,6 +1112,8 @@
>::type
__unwrap_iter(__wrap_iter<_Tp*>);
+template <class _Tp, class _Alloc> class vector;
+
template <class _Iter>
class __wrap_iter
{
Index: test/std/iterators/iterators.general/gcc_workaround.pass.cpp
===================================================================
--- test/std/iterators/iterators.general/gcc_workaround.pass.cpp
+++ 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 <string>
+
+void f(const std::string &s) { s.begin(); }
+
+#include <vector>
+
+void AppendTo(const std::vector<char> &v) { v.begin(); }
+
+int main() {}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7201.18822.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150127/f75f0218/attachment.bin>
More information about the cfe-commits
mailing list