[cfe-dev] (no subject)
Csaba Raduly
rcsaba at gmail.com
Mon Dec 1 05:34:39 PST 2014
Compiling the following code:
#include <memory>
#include <vector>
#include <initializer_list>
struct C {
std::vector< std::unique_ptr<int> > vec;
C(std::initializer_list< std::unique_ptr<int> > init)
: vec(std::make_move_iterator(init.begin()),
std::make_move_iterator(init.end()))
{}
};
with clang version 3.6.0 (trunk 222993) (llvm/trunk 222992)
resulted in a perplexing message:
In file included from wtf.cc:1:
In file included from
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../gcc/x86_64-unknown-linux-gnu/4.9.0/include/c++/memory:62:
In file included from
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../gcc/x86_64-unknown-linux-gnu/4.9.0/include/c++/bits/stl_algobase.h:67:
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../gcc/x86_64-unknown-linux-gnu/4.9.0/include/c++/bits/stl_iterator.h:995:16:
error: binding of reference to type 'unique_ptr<[2 * ...]>' to a value
of type 'unique_ptr<[2 * ...]>' drops qualifiers
{ return std::move(*_M_current); }
^~~~~~~~~~~~~~~~~~~~~~
I can see no qualifiers to be dropped
(although std::initializer_list gives only const access to its contents)
GCC's error message sheds a bit more light on what's wrong:
/usr/include/c++/4.8/bits/stl_iterator.h:963:37: error: invalid
initialization of reference of type 'std::move_iterator<const
std::unique_ptr<int>*>::reference {aka std::unique_ptr<int>&&}' from
expression of type 'std::remove_reference<const
std::unique_ptr<int>&>::type {aka const std::unique_ptr<int>}'
{ return std::move(*_M_current); }
^
Note the presence of 'const' in the GCC error message, as opposed to clang
(which makes no mention of const).
Csaba
(please excuse ghastly formatting by Gmail)
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus
Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141201/ddf655a4/attachment.html>
More information about the cfe-dev
mailing list