<html>
<head>
<base href="https://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 --- - Unexpected compile time error with vector<bool>"
href="https://llvm.org/bugs/show_bug.cgi?id=30357">30357</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unexpected compile time error with vector<bool>
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>billy.jasiniecki@hpe.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>An test case (that is an excerpt from a standard validation test) gets an error
when compiled with both g++ and clang, but only with headers from libc++. When
the same test case is compiled using gnu headers, the test compiles cleanly.
The test case:
#include <vector>
struct alloc : std::allocator<bool> {};
int main(void)
{
std::vector<bool> v1;
std::vector<bool, alloc>::reference r01 = v1[0];
}
With clang:
$ clang -c t.cpp -std=c++11 -Ic:/downloads/libcxx-3.8.1.src/include
t265.cpp:6:45: error: no viable conversion from '__bit_reference<vector<[...],
std::__1::allocator<bool>>>' to
'__bit_reference<vector<[...], alloc>>'
std::vector<bool, alloc>::reference r01 = v1[0];
^ ~~~~~
c:/downloads/libcxx-3.8.1.src/include/__bit_reference:35:7: note: candidate
constructor (the implicit copy constructor) not viable: no known
conversion from 'reference' (aka '__bit_reference<std::__1::vector<bool,
std::__1::allocator<bool> > >') to 'const
std::__1::__bit_reference<std::__1::vector<bool, alloc>, true> &' for 1st
argument
class __bit_reference
^
c:/downloads/libcxx-3.8.1.src/include/__bit_reference:51:31: note: candidate
function
_LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
^
1 error generated.
With g++:
$ g++ -c t.cpp -std=c++11 -Ic:/downloads/libcxx-3.8.1.src/include
t265.cpp: In function ‘int main()’:
t265.cpp:6:55: error: conversion from ‘std::__1::vector<bool>::reference {aka
std::__1::__bit_reference<std::__1::vector<bool>, true>}’ to non-scalar type
‘std::__1::vector<bool, alloc>::reference {aka
std::__1::__bit_reference<std::__1::vector<bool, alloc>, true>}’ requested
std::vector<bool, alloc>::reference r01 = v1[0];
The test case also compiles cleanly when headers from Dinkumware are used.</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>