<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - __wrap_iter's private constructor runs into a bug with gcc"
href="http://llvm.org/bugs/show_bug.cgi?id=22353">22353</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__wrap_iter's private constructor runs into a bug with gcc
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>When using libc++ with gcc, this program doesn't compile:
#include <string>
void f(const std::string& s) {
s.begin();
}
#include <vector>
void AppendTo(const std::vector<char>& v) {
v.begin();
}
[reply] [-] Description Nico Weber 2015-01-24 23:40:08 CST
clang accepts the following code, which gcc, cl, icc all reject. icc says
"warning #525: type "A<void>::const_pointer" (declared at line 3) is an
inaccessible type (allowed for cfront compatibility)", so this is probably a
clang bug (?)
$ cat repro.ii
template <class T1> class A;
template <> class A<void> {
typedef void *const_pointer;
};
template <class T1> class A {
void m_fn1(A<void>::const_pointer);
};
class F {
A<int> const_pointer;
};
$ bin/clang -c repro.ii
$ gcc-4.8.1 -c repro.ii
gcc-4.8.1: warning: couldn’t understand kern.osversion ‘14.0.0
repro.ii: In instantiation of ‘class A<int>’:
repro.ii:9:10: required from here
repro.ii:3:17: error: ‘typedef void* A<void>::const_pointer’ is private
typedef void *const_pointer;
^
repro.ii:6:23: error: within this context
void m_fn1(A<void>::const_pointer);
^
[reply] [-] <a href="show_bug.cgi?id=22353#c1">Comment 1</a> Nico Weber 2015-01-24 23:40:32 CST
Oh, and libc++ seems to depend on this bug :-/
[reply] [-] <a href="show_bug.cgi?id=22353#c2">Comment 2</a> Nico Weber 2015-01-25 01:09:30 CST
Here's a snippet that doesn't build with gcc and libc++ but does build with
clang and libc++:
#include <string>
void f(const std::string& s) {
s.begin();
}
#include <vector>
void AppendTo(const std::vector<char>& v) {
v.begin();
}
$ bin/clang -c repro.cc -I ~/src/libcxx/include/ -isysroot $(xcrun
-show-sdk-path)
$ gcc-4.8.1 -c repro.cc -I ~/src/libcxx/include/ -isysroot $(xcrun
-show-sdk-path)
gcc-4.8.1: warning: couldn’t understand kern.osversion ‘14.0.0
In file included from /Users/thakis/src/libcxx/include/memory:604:0,
from /Users/thakis/src/libcxx/include/algorithm:628,
from /Users/thakis/src/libcxx/include/string:439,
from repro.cc:1:
/Users/thakis/src/libcxx/include/vector: In instantiation of
‘std::__1::vector<_Tp, _Allocator>::const_iterator std::__1::vector<_Tp,
_Allocator>::__make_iter(std::__1::vector<_Tp, _Allocator>::const_pointer)
const [with _Tp = char; _Allocator = std::__1::allocator<char>;
std::__1::vector<_Tp, _Allocator>::const_iterator = std::__1::__wrap_iter<const
char*>; typename std::__1::__vector_base<_Tp, _Allocator>::const_pointer =
const char*; std::__1::vector<_Tp, _Allocator>::const_pointer = const char*]’:
/Users/thakis/src/libcxx/include/vector:1480:38: required from
‘std::__1::vector<_Tp, _Allocator>::const_iterator std::__1::vector<_Tp,
_Allocator>::begin() const [with _Tp = char; _Allocator =
std::__1::allocator<char>; std::__1::vector<_Tp, _Allocator>::const_iterator =
std::__1::__wrap_iter<const char*>; typename std::__1::__vector_base<_Tp,
_Allocator>::const_pointer = const char*]’
repro.cc:42:11: required from here
/Users/thakis/src/libcxx/include/iterator:1228:31: error:
‘std::__1::__wrap_iter<_Iter>::__wrap_iter(std::__1::__wrap_iter<_Iter>::iterator_type)
[with _Iter = const char*; std::__1::__wrap_iter<_Iter>::iterator_type = const
char*]’ is private
_LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT :
__i(__x) {}
^
In file included from repro.cc:7:0:
/Users/thakis/src/libcxx/include/vector:1463:30: error: within this context
return const_iterator(__p);
Depending on how you reduce, this turns up different issues. My best reduction
so far shows a bug in gcc: <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816</a>
(but note point (1.) at the bottom, this kind of suggests that I over-reduced –
might still be the same bug though, so best to see if a fix for that bug helps
here too). But since vector is a friend of __wrap_iter, this is clearly some
gcc bug.
I found a clang bug while reducing this too (issue 22350), but on second look
it appears unrelated.
I have a libc++-side workaround for this that makes everything work with
current gccs. With that workaround, I'm able to build chromium/android with
libc++ and gcc. WIthout the workaround, 2 (out of 20000) translation units fail
to build, on innocuous code.
I'll send out the workaround to the list.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>