* [C++0x unique_ptr] sorting a vector of unique_ptr fails
@ 2008-12-13 17:35 René Bürgel
2008-12-15 19:30 ` Ian Lance Taylor
0 siblings, 1 reply; 8+ messages in thread
From: René Bürgel @ 2008-12-13 17:35 UTC (permalink / raw)
To: gcc-help
Hello!
Is the following code supposed to work in C++0x-Mode or am i just doing
something wrong?
#include <memory>
#include <vector>
#include <algorithm>
int main()
{
std::vector<std::unique_ptr<int> > v;
std::sort(v.begin(), v.end());
}
g++-4.4.0-alpha20081107 -std=c++0x bug.cpp gives me:
In file included from
/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/algorithm:67,
from
../../bug.cpp:3:
/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/unique_ptr.h:
In function 'void std::__introsort_loop(_RandomAccessIterator,
_RandomAccessIterator, _Size) [with _RandomAccessIterator =
__gnu_cxx::__normal_iterator<std::unique_ptr<int,
std::default_delete<int> >*, std::vector<std::unique_ptr<int,
std::default_delete<int> >, std::allocator<std::unique_ptr<int,
std::default_delete<int> > > > >, _Size =
int]':
/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/stl_algo.h:5152:
instantiated from 'void std::sort(_RAIter, _RAIter) [with _RAIter =
__gnu_cxx::__normal_iterator<std::unique_ptr<int,
std::default_delete<int> >*, std::vector<std::unique_ptr<int,
std::default_delete<int> >, std::allocator<std::unique_ptr<int,
std::default_delete<int> > > > >]'
../../bug.cpp:10: instantiated from
here
/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/unique_ptr.h:215:
error: deleted function 'std::unique_ptr<_Tp,
_Tp_Deleter>::unique_ptr(const std::unique_ptr<_Tp, _Tp_Deleter>&) [with
_Tp = int, _Tp_Deleter =
std::default_delete<int>]'
/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/stl_algo.h:2249:
error: used here
[...]
Thanks in advance
René
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-13 17:35 [C++0x unique_ptr] sorting a vector of unique_ptr fails René Bürgel
@ 2008-12-15 19:30 ` Ian Lance Taylor
2008-12-15 20:22 ` Christopher Jefferson
0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2008-12-15 19:30 UTC (permalink / raw)
To: René Bürgel; +Cc: gcc-help
René Bürgel <rbuergel@web.de> writes:
> Is the following code supposed to work in C++0x-Mode or am i just
> doing something wrong?
>
> #include <memory>
> #include <vector>
> #include <algorithm>
>
> int main()
> {
> std::vector<std::unique_ptr<int> > v;
> std::sort(v.begin(), v.end());
> }
I think it is supposed to work. The standard says that the value
must be Swappable, MoveConstructible, and MoveAssignable. I think
that std::unique_ptr meets those requirements.
I think this is a bug in libstdc++-v3. Looking at the code, I think
this means that __introsort_loop can't assume that it can pass values
to std::__median.
Ian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-15 19:30 ` Ian Lance Taylor
@ 2008-12-15 20:22 ` Christopher Jefferson
2008-12-15 23:46 ` René Bürgel
0 siblings, 1 reply; 8+ messages in thread
From: Christopher Jefferson @ 2008-12-15 20:22 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: René Bürgel, gcc-help
On 15 Dec 2008, at 19:28, Ian Lance Taylor wrote:
> René Bürgel <rbuergel@web.de> writes:
>
>> Is the following code supposed to work in C++0x-Mode or am i just
>> doing something wrong?
>>
>> #include <memory>
>> #include <vector>
>> #include <algorithm>
>>
>> int main()
>> {
>> std::vector<std::unique_ptr<int> > v;
>> std::sort(v.begin(), v.end());
>> }
>
> I think it is supposed to work. The standard says that the value
> must be Swappable, MoveConstructible, and MoveAssignable. I think
> that std::unique_ptr meets those requirements.
>
> I think this is a bug in libstdc++-v3. Looking at the code, I think
> this means that __introsort_loop can't assume that it can pass values
> to std::__median.
It is a "bug" in that not all of libstdc++-v3 has been updated to C+
+0x. Sort is one such example.
Chris
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-15 20:22 ` Christopher Jefferson
@ 2008-12-15 23:46 ` René Bürgel
2008-12-16 6:14 ` Ian Lance Taylor
0 siblings, 1 reply; 8+ messages in thread
From: René Bürgel @ 2008-12-15 23:46 UTC (permalink / raw)
To: Christopher Jefferson, gcc-help
Christopher Jefferson schrieb:
>
> On 15 Dec 2008, at 19:28, Ian Lance Taylor wrote:
>
>> René Bürgel <rbuergel@web.de> writes:
>>
>>> Is the following code supposed to work in C++0x-Mode or am i just
>>> doing something wrong?
>>>
>>> #include <memory>
>>> #include <vector>
>>> #include <algorithm>
>>>
>>> int main()
>>> {
>>> std::vector<std::unique_ptr<int> > v;
>>> std::sort(v.begin(), v.end());
>>> }
>>
>> I think it is supposed to work. The standard says that the value
>> must be Swappable, MoveConstructible, and MoveAssignable. I think
>> that std::unique_ptr meets those requirements.
>>
>> I think this is a bug in libstdc++-v3. Looking at the code, I think
>> this means that __introsort_loop can't assume that it can pass values
>> to std::__median.
>
>
> It is a "bug" in that not all of libstdc++-v3 has been updated to
> C++0x. Sort is one such example.
>
> Chris
Would it be useful to file a bugreport (at least for keeping track of
this) or can this fact be assumed to be commonly known by the
responsible persons, meaning that it is on their todo-list anyway? Maybe
i can take a closer look at this during the xmas holiday and create a
patch to fix this issue. Would this need any paperworks with the FSF?
René
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-15 23:46 ` René Bürgel
@ 2008-12-16 6:14 ` Ian Lance Taylor
2008-12-17 0:44 ` René Bürgel
0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2008-12-16 6:14 UTC (permalink / raw)
To: René Bürgel; +Cc: Christopher Jefferson, gcc-help
René Bürgel <rbuergel@web.de> writes:
> Maybe i can take a closer look at this during the xmas holiday and
> create a patch to fix this issue. Would this need any paperworks with
> the FSF?
Yes, a patch for this would require paperwork with the FSF. If you
are interested, let me know, and I will send you what you need to
start the process. Thanks.
Ian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-16 6:14 ` Ian Lance Taylor
@ 2008-12-17 0:44 ` René Bürgel
2008-12-17 0:50 ` Diego Novillo
0 siblings, 1 reply; 8+ messages in thread
From: René Bürgel @ 2008-12-17 0:44 UTC (permalink / raw)
To: Ian Lance Taylor, gcc-help
> If you
> are interested, let me know, and I will send you what you need to
> start the process. Thanks.
>
> Ian
>
Thanks, i'd appreciate that.
Is there anyone, that can act as a kind of mentor, just for the case,
that some questions will come up? I consider myself still as a junior
software developer, although i'm quite experienced in C++ including a
good understandig of template metaprogramming.
René
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-17 0:44 ` René Bürgel
@ 2008-12-17 0:50 ` Diego Novillo
2008-12-17 1:06 ` Diego Novillo
0 siblings, 1 reply; 8+ messages in thread
From: Diego Novillo @ 2008-12-17 0:50 UTC (permalink / raw)
To: René Bürgel; +Cc: Ian Lance Taylor, gcc-help
On Tue, Dec 16, 2008 at 19:44, René Bürgel <rbuergel@web.de> wrote:
> Is there anyone, that can act as a kind of mentor, just for the case, that
> some questions will come up? I consider myself still as a junior software
> developer, although i'm quite experienced in C++ including a good
> understandig of template metaprogramming.
There are three main resources you can use:
1- Wiki: http://gcc.gnu.org/wiki/GettingStarted has links to some
internal documentation, presentations, papers, etc.
2- IRC: irc://irc.oftc.net/#gcc: several of us hang out in that
channel and you'll usually find somebody to answer your question or
point you in the general direction.
3- Mailing lists: You can mail your question to gcc@gcc.gnu.org, this
may take longer than the other 2, but is also a good resource.
Diego.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++0x unique_ptr] sorting a vector of unique_ptr fails
2008-12-17 0:50 ` Diego Novillo
@ 2008-12-17 1:06 ` Diego Novillo
0 siblings, 0 replies; 8+ messages in thread
From: Diego Novillo @ 2008-12-17 1:06 UTC (permalink / raw)
To: René Bürgel; +Cc: Ian Lance Taylor, gcc-help
On Tue, Dec 16, 2008 at 19:44, René Bürgel <rbuergel@web.de> wrote:
> Is there anyone, that can act as a kind of mentor, just for the case, that
> some questions will come up? I consider myself still as a junior software
> developer, although i'm quite experienced in C++ including a good
> understandig of template metaprogramming.
There are three main resources you can use:
1- Wiki: http://gcc.gnu.org/wiki/GettingStarted has links to some
internal documentation, presentations, papers, etc.
2- IRC: irc://irc.oftc.net/#gcc: several of us hang out in that
channel and you'll usually find somebody to answer your question or
point you in the general direction.
3- Mailing lists: You can mail your question to gcc@gcc.gnu.org, this
may take longer than the other 2, but is also a good resource.
Diego.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-12-17 0:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-13 17:35 [C++0x unique_ptr] sorting a vector of unique_ptr fails René Bürgel
2008-12-15 19:30 ` Ian Lance Taylor
2008-12-15 20:22 ` Christopher Jefferson
2008-12-15 23:46 ` René Bürgel
2008-12-16 6:14 ` Ian Lance Taylor
2008-12-17 0:44 ` René Bürgel
2008-12-17 0:50 ` Diego Novillo
2008-12-17 1:06 ` Diego Novillo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).