[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] C++11
From: |
Stephen Leake |
Subject: |
Re: [Monotone-devel] C++11 |
Date: |
Fri, 16 May 2014 12:47:42 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (windows-nt) |
On msys2:
g++ --version
g++.exe (Rev2, Built by MSYS2 project) 4.9.0
g++ -I. -I../mandatory-cxx11 -I/mingw64/include
-I/mingw64/include/botan-1.10 -DWIN32 -DNETXX_NO_PTON -DNETXX_NO_NTOP
-DNETXX_NO_INET6 -g -O2 -Wall -Wextra -Wno-unused -Wno-unused-parameter
-std=c++11 -MT src/roster.o -MD -MP -MF $depbase.Tpo -c -o src/roster.o
../mandatory-cxx11/src/roster.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from
C:/Msys2/msys64/mingw64/include/c++/4.9.0/bits/shared_ptr.h:52:0,
from C:/Msys2/msys64/mingw64/include/c++/4.9.0/memory:82,
from ../mandatory-cxx11/src/roster.cc:14:
C:/Msys2/msys64/mingw64/include/c++/4.9.0/bits/shared_ptr_base.h: In
instantiation of 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*) [with _Tp1 =
cow_trie<unsigned int, std::shared_ptr<marking>, 8>::middle_node_type; _Tp =
void; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]':
C:/Msys2/msys64/mingw64/include/c++/4.9.0/bits/shared_ptr_base.h:1023:4:
required from 'void std::__shared_ptr<_Tp, _Lp>::reset(_Tp1*) [with _Tp1 =
cow_trie<unsigned int, std::shared_ptr<marking>, 8>::middle_node_type; _Tp =
void; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]'
../mandatory-cxx11/src/cow_trie.hh:48:4: required from 'bool cow_trie<_Key,
_Value, _Bits>::walk(std::shared_ptr<void>&, _Key, int, _Value**) [with _Key =
unsigned int; _Value = std::shared_ptr<marking>; int _Bits = 8]'
../mandatory-cxx11/src/cow_trie.hh:135:38: required from 'const _Value&
cow_trie<_Key, _Value, _Bits>::get_unshared_if_present(_Key) [with _Key =
unsigned int; _Value = std::shared_ptr<marking>; int _Bits = 8]'
../mandatory-cxx11/src/roster.cc:212:59: required from here
C:/Msys2/msys64/mingw64/include/c++/4.9.0/bits/shared_ptr_base.h:874:4: error:
static assertion failed: incomplete type
static_assert( !is_void<_Tp>::value, "incomplete type" );
I think the problem is in cow_trie.hh:
bool walk(std::shared_ptr<void> & d, _Key key, int level, _Value **ret)
{
if (!d)
{
if (level > 0)
d.reset(new middle_node_type());
else
d.reset(new leaf_node_type());
}
Apparently 'std::shared_ptr<void>' is illegal, and that is enforced in
gcc 4.9.0
I don't have the c++11 reference manual. I found this:
http://en.cppreference.com/w/cpp/memory/shared_ptr
std::shared_ptr may be used with an incomplete type T, but T must be
complete at the point in code where the constructor from a raw
pointer or the reset(T*) member function is called (note that
std::unique_ptr may be constructed from a raw pointer to an
incomplete type).
I assume 'void' is an incomplete type.
The parameter 'd' in 'walk' is used to pass cow_trie::_data.
cow_trie::_data is set by the 'walk' code above; apparently we have two
node types. So to use a shared_ptr, we need a union of those types.
Can we use a unique_ptr here? I don't see where _data is shared. Guess I
should just try it: no, that gives a different error:
g++ -I. -I../mandatory-cxx11 -I/mingw64/include
-I/mingw64/include/botan-1.10 -DWIN32 -DNETXX_NO_PTON -DNETXX_NO_NTOP
-DNETXX_NO_INET6 -g -O2 -Wall -Wextra -Wno-unused -Wno-unused-parameter
-std=c++11 -MT src/cmd_netsync.o -MD -MP -MF $depbase.Tpo -c -o
src/cmd_netsync.o ../mandatory-cxx11/src/cmd_netsync.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from C:/Msys2/msys64/mingw64/include/c++/4.9.0/memory:81:0,
from
C:/Msys2/msys64/mingw64/include/boost/container/container_fwd.hpp:36,
from
C:/Msys2/msys64/mingw64/include/boost/lexical_cast.hpp:170,
from ../mandatory-cxx11/src/lexical_cast.hh:13,
from ../mandatory-cxx11/src/option.hh:29,
from ../mandatory-cxx11/src/options.hh:26,
from ../mandatory-cxx11/src/commands.hh:14,
from ../mandatory-cxx11/src/cmd.hh:17,
from ../mandatory-cxx11/src/cmd_netsync.cc:13:
C:/Msys2/msys64/mingw64/include/c++/4.9.0/bits/unique_ptr.h: In instantiation
of 'void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = void]':
C:/Msys2/msys64/mingw64/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>]'
../mandatory-cxx11/src/cow_trie.hh:20:7: required from here
C:/Msys2/msys64/mingw64/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,
So we need a union type.
--
-- Stephe
- Re: [Monotone-devel] C++11, (continued)
- Re: [Monotone-devel] C++11, Hendrik Boom, 2014/05/16
- Re: [Monotone-devel] C++11, Markus Wanner, 2014/05/16
- Re: [Monotone-devel] C++11, Hendrik Boom, 2014/05/16
- Re: [Monotone-devel] C++11, Stephen Leake, 2014/05/16
- Re: [Monotone-devel] C++11, Hendrik Boom, 2014/05/16
Re: [Monotone-devel] C++11, Markus Wanner, 2014/05/16
Re: [Monotone-devel] C++11,
Stephen Leake <=
Re: [Monotone-devel] C++11, Stephen Leake, 2014/05/16