yanyiwu / gojieba

"结巴"中文分词的Golang版本
MIT License
2.39k stars 302 forks source link

在Ubuntu上编译运行时出现很多C++警告信息 #68

Open tengge1 opened 4 years ago

tengge1 commented 4 years ago

系统:Ubuntu 20.04LTS

版本:

github.com/yanyiwu/gojieba v1.1.0 h1:rx+kNP0L7zn+4Zyo1d8aLCfXt3BmIkWQ26FCbGnw1bc=
github.com/yanyiwu/gojieba v1.1.0/go.mod h1:0AAj9tOG6WWXQ5FNffl4ruBy/hP7bHl2gs+YiDi1aYs=

信息:

# github.com/yanyiwu/gojieba
In file included from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Unicode.hpp:9,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/DictTrie.hpp:15,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/QuerySegment.hpp:8,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Jieba.hpp:4,
                 from jieba.cpp:5:
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/limonp/LocalVector.hpp: In instantiation of ‘void limonp::LocalVector<T>::reserve(size_t) [with T = std::pair<long unsigned int, const cppjieba::DictUnit*>; size_t = long unsigned int]’:
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/limonp/LocalVector.hpp:83:7:   required from ‘void limonp::LocalVector<T>::push_back(const T&) [with T = std::pair<long unsigned int, const cppjieba::DictUnit*>]’
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Trie.hpp:99:81:   required from here
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/limonp/LocalVector.hpp:95:11: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<long unsigned int, const cppjieba::DictUnit*>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
   95 |     memcpy(ptr_, old, sizeof(T) * capacity_);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/utility:70,
                 from /usr/include/c++/9/algorithm:60,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/QuerySegment.hpp:4,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Jieba.hpp:4,
                 from jieba.cpp:5:
/usr/include/c++/9/bits/stl_pair.h:208:12: note: ‘struct std::pair<long unsigned int, const cppjieba::DictUnit*>’ declared here
  208 |     struct pair
      |            ^~~~
In file included from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Unicode.hpp:9,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/DictTrie.hpp:15,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/QuerySegment.hpp:8,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Jieba.hpp:4,
                 from jieba.cpp:5:
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/limonp/LocalVector.hpp: In instantiation of ‘limonp::LocalVector<T>& limonp::LocalVector<T>::operator=(const limonp::LocalVector<T>&) [with T = std::pair<long unsigned int, const cppjieba::DictUnit*>]’:
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/limonp/LocalVector.hpp:33:11:   required from ‘limonp::LocalVector<T>::LocalVector(const limonp::LocalVector<T>&) [with T = std::pair<long unsigned int, const cppjieba::DictUnit*>]’
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Trie.hpp:28:8:   required from ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = cppjieba::Dag; _Args = {const cppjieba::Dag&}]’
/usr/include/c++/9/bits/stl_uninitialized.h:83:18:   required from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const cppjieba::Dag*; _ForwardIterator = cppjieba::Dag*; bool _TrivialValueTypes = false]’
/usr/include/c++/9/bits/stl_uninitialized.h:140:15:   required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const cppjieba::Dag*; _ForwardIterator = cppjieba::Dag*]’
/usr/include/c++/9/bits/stl_uninitialized.h:307:37:   required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = const cppjieba::Dag*; _ForwardIterator = cppjieba::Dag*; _Tp = cppjieba::Dag]’
/usr/include/c++/9/bits/stl_uninitialized.h:329:2:   required from ‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = cppjieba::Dag*; _ForwardIterator = cppjieba::Dag*; _Allocator = std::allocator<cppjieba::Dag>]’
/usr/include/c++/9/bits/vector.tcc:659:48:   required from ‘void std::vector<_Tp, _Alloc>::_M_default_append(std::vector<_Tp, _Alloc>::size_type) [with _Tp = cppjieba::Dag; _Alloc = std::allocator<cppjieba::Dag>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]’
/usr/include/c++/9/bits/stl_vector.h:937:4:   required from ‘void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = cppjieba::Dag; _Alloc = std::allocator<cppjieba::Dag>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]’
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Trie.hpp:86:27:   required from here
../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/limonp/LocalVector.hpp:63:13: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<long unsigned int, const cppjieba::DictUnit*>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
   63 |       memcpy(ptr_, vec.ptr_, vec.size() * sizeof(T));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/utility:70,
                 from /usr/include/c++/9/algorithm:60,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/QuerySegment.hpp:4,
                 from ../../../go/pkg/mod/github.com/yanyiwu/gojieba@v1.1.0/deps/cppjieba/Jieba.hpp:4,
                 from jieba.cpp:5:
/usr/include/c++/9/bits/stl_pair.h:208:12: note: ‘struct std::pair<long unsigned int, const cppjieba::DictUnit*>’ declared here
  208 |     struct pair
      |            ^~~~
terry2010 commented 4 years ago

在 centos8 下静态编译, 也会出现类似的警告信息

izturn commented 4 years ago

win10 上也会出现类似警告

Ioridy commented 4 years ago

同样windows10 和CentOS 7.6出现此问题,有人解决了吗?

ttys3 commented 4 years ago

this may fix:

in go.mod append this line:

replace github.com/yanyiwu/gojieba v1.1.2 => github.com/ttys3/gojieba v1.1.3

remember to run go clean -cache , then go build . , the warning disappeared.

this is a temp solution, I've created a PR https://github.com/yanyiwu/gojieba/pull/70 to fix this.

I hope the PR will be merged to the master

w4-hanggi commented 3 years ago

Is it fixed? It still happens in both linux and window10.

mmcer commented 3 years ago

currently i still can get this issue on my latest win10 21H1.