Possible bug in gcc handling of std::unique_ptr<void>
Jonathan Wakely
jwakely.gcc@gmail.com
Fri Nov 8 16:05:00 GMT 2013
On 8 November 2013 15:57, Andy Falanga (afalanga) wrote:
> Hi all,
>
> I asked this question on Stack Overflow (http://stackoverflow.com/questions/19840937/should-stdunique-ptrvoid-be-permitted). The question, "Should std::unqiue_ptr<void> be permitted?" As is referenced in the SO article, consider this code:
>
> #include <iostream>
> #include <memory>
>
> typedef std::unique_ptr<void> UniqueVoidPtr;
>
> int main() {
> UniqueVoidPtr p(new int);
> return 0;
> }
>
> I am using cygwin G++ 4.5.3 for comparison. Using this compilation command, I receive no issues (complaints) from the compiler and the program runs without issue:
>
> g++ -Wall -std=c++0x -o <output> file.cpp
Not on trunk, I fixed it last week:
In file included from /home/redi/gcc/4.x/include/c++/4.9.0/memory:81:0,
from up.cc:2:
/home/redi/gcc/4.x/include/c++/4.9.0/bits/unique_ptr.h: In
instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*)
const [with _Tp = void]’:
/home/redi/gcc/4.x/include/c++/4.9.0/bits/unique_ptr.h:236:16:
required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp =
void; _Dp = std::default_delete<void>]’
up.cc:7:28: required from here
/home/redi/gcc/4.x/include/c++/4.9.0/bits/unique_ptr.h:72:2: error:
static assertion failed: can't delete pointer to incomplete type
static_assert(!is_void<_Tp>::value,
^
More information about the Gcc-help
mailing list