LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 22355 - __wrap_iter's private constructor runs into a bug with gcc
Summary: __wrap_iter's private constructor runs into a bug with gcc
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 22353 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-01-27 11:49 PST by Nico Weber
Modified: 2015-01-30 15:10 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Weber 2015-01-27 11:49:52 PST
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(); }
```


$ 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: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816 (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.
Comment 1 Nico Weber 2015-01-27 11:50:06 PST
*** Bug 22353 has been marked as a duplicate of this bug. ***
Comment 2 Nico Weber 2015-01-27 11:53:27 PST
Patch: http://reviews.llvm.org/D7201
Comment 3 Nico Weber 2015-01-30 15:10:44 PST
r227226