Closed JonHodgson closed 8 years ago
@JonHodgson Thanks for reporting! If I'm reading the error fire-hose right, this is also a manifestation of #16. I have a candidate fix at PR #17. The previous reporter never responded, but I'm curious if you can test this PR before I officially merge it.
@erikerlandson Sorry, but that was the PR I was building.
I've attached the full output of a build of the "test" project, in html format buildlog.html.zip
@JonHodgson Sorry, I didn't catch that you tried the issue-16 branch.
It may be difficult for me to reproduce this as I don't have Xcode, however I see that Xcode uses the clang toolchain; if you can get me your Xcode version I might be able to build a corresponding version of clang on my linux box: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
If you want to play with making any protected
members public to see if it causes the problem to go away, that might at least get you a workaround
Just as a data point, my default clang successfully builds st_tree, but it is version 3.7.0
I'm running Xcode 7.2.1, on Yosemite. And just in case it matters, boost 1.58.0
My investigation into Xcode versions of clang suggests that there is, sadly, no well-defined mapping between Xcode releases and other clang releases. In lieu of that, I tried building st_tree against all the clang-3.x series, but I failed to reproduce the compile failure.
Clang did turn up some other errors in a few of my operator=
methods, which I fixed. I also merged #17 and cut a new release:
https://github.com/erikerlandson/st_tree/releases/tag/version_1.0.4
You might try that just to see what happens, although I have no evidence that it would fix this problem with Xcode.
Regarding boost, I am also building against 1.58
A note on clang - they appear to be only maintaining the tips of their release branches, so for example the release_36
branch corresponds to 3.6.2, but I can't find a way to reconstruct 3.6.1, etc. So I have been building the most-recent minor release of each 3.x series
That update didn't help much, but I think I've made progress. It looks like the issue isn't the compiler, it's the standard library. Apple uses the LLVM libcxx, which includes certain checks
https://llvm.org/svn/llvm-project/libcxx/trunk/include/vector
Note line in the definition of vector
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
Now in your code, you have a bunch of places where you're declaring a vector with a different allocator to the value_type. You're using the Allocator declared for the tree, but that is an allocator for the tree value type.
e.g. vector<Unsigned, Alloc> _hist;
As a test I went through and commented out all those allocators, and most of the errors vanished. In fact right now it looks like the errors I still have are in the test code, not the tree code (though saying that I've commented out a lot of the tests, so maybe re-instantiating them will pop more issues).
It turns out that the last errors I was getting were also from a mismatched allocator, this time in a deque Attached is a zip of source that builds fine with all tests passing. I've just commented out the allocators. source.zip
@JonHodgson that is a great find, thanks for all your help! It has been interesting to see the errors that more recent releases of clang
have found hiding in this code, even though I had it passing all my unit testing and valgrind with both g++ and clang++ a few years ago.
I can add llvm's version of libc++ to my clang build, which hopefully will enable me to reproduce this locally.
@JonHodgson I believe I figured it out -- the gnu STL re-casts its allocator under the hood to the correct value type, but the clang/llvm incarnation is more picky and it wants the allocator type you pass in to already match the container's value type.
I pushed a change to master
that provides allocator types that are aligned with corresponding container value types, so the clang/llvm libcxx is now happy.
@erikerlandson Hi, sorry I didn't respond earlier but I was working on the windows version of my app. What you've done seems to have worked, successful compilation in XCode. Thanks.
@JonHodgson that is great news. I'll close this issue. Thanks again for your work on diagnosing the problem!
I've been compiling and using the library successfully in Visual Studio 2013 (well apart from one small fix), but when I try to compile the test and example projects in Xcode, all hell breaks loose, with 168 errors. This happens whether I use my modified version, or the latest Master or 16 branch form GitHub.
Taking just one file as an example..
At line 147 of st_tree-nodes.h
typedef typename base_type::cs_iterator cs_iterator;
The error given is that cs_iterator is a protected member of the base_type. But base_type is a public parent of the class, so that would seem to be ok. .
CompileC /Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/st_tree.build/Debug/x06_graft.build/Objects-normal/x86_64/x06_graft.o examples/x06_graft.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler cd /Users/jon/Downloads/st_tree-master export LANG=en_US.US-ASCII /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.10 -g -Wno-sign-conversion -I/Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/Debug/include -I/Users/jon/Downloads/st_tree-master/include -I/Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/st_tree.build/Debug/x06_graft.build/DerivedSources/x86_64 -I/Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/st_tree.build/Debug/x06_graft.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/Debug -MMD -MT dependencies -MF /Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/st_tree.build/Debug/x06_graft.build/Objects-normal/x86_64/x06_graft.d --serialize-diagnostics /Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/st_tree.build/Debug/x06_graft.build/Objects-normal/x86_64/x06_graft.dia -c /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp -o /Volumes/BOOTCAMP/Users/Jon/Documents/Visual\ Studio\ 2013/Projects/WPF/BuildOSX/st_tree_master/examples/st_tree.build/Debug/x06_graft.build/Objects-normal/x86_64/x06_graft.o
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28: In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:97: In file included from /Users/jon/Downloads/st_tree-master/include/st_tree_detail.h:24: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:499:5: error: implicit instantiation of undefined template 'static_assert_test'
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:22:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:434:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:553:35: note: expanded from macro 'static_assert'
typedef static_assert_check<sizeof(static_assert_test<(b)>)> \
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:105:
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:47:22: note: in instantiation of template class 'std::1::vector<st_tree::detail::node_raw<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::__1::basic_string >, std:: 1::basicstring > , std::1::allocatorstd::1::basic_string >' requested here
typedef typename cs_type::iterator cs_iterator;
^
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:272:25: note: in instantiation of template class 'st_tree::detail::node_base<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::1::basic_string >, st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basic_string >, std::__1::vector<st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basic_string > *, std::1::allocatorstd::1::basic_string > >' requested here
struct node_raw: public node_base<Tree, node_raw<Tree, Data>, vector<noderaw<Tree, Data>, typename Tree::allocator_type> > {
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
/Users/jon/Downloads/st_tree-master/include/st_tree.h:127:22: note: in instantiation of template class 'st_tree::detail::node_raw<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::__1::basic_string >, std:: 1::basic_string >' requested here
typedef typename node_type::base_type node_base_type;
^
/Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:35:18: note: in instantiation of template class 'st_tree::treestd::1::basic_string<char, st_tree::raw, std:: 1::allocatorstd::1::basic_string >' requested here
tree t;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:22:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:434:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/config:549:24: note: template is declared here
template struct static_assert_test;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:97:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree_detail.h:24:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:499:5: error: implicit instantiation of undefined template ' static_assert_test'
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:22:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:434:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/config:553:35: note: expanded from macro 'static_assert'
typedef static_assert_check<sizeof(static_assert_test<(__b)>)> \
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:97:
/Users/jon/Downloads/st_tree-master/include/st_tree_detail.h:112:29: note: in instantiation of template class 'std::1::vector<unsigned long, std::1::allocator<std::1::basic_string > >' requested here
vector<Unsigned, Alloc> _hist;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:105:
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:180:47: note: in instantiation of template class 'st_tree::detail::max_maintainer<unsigned long, std::1::allocator<std::1::basic_string > >' requested here
max_maintainer<size_type, allocator_type> _depth;
^
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:272:25: note: in instantiation of template class 'st_tree::detail::node_base<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::1::basic_string >, st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basic_string >, std::__1::vector<st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basicstring > , std::1::allocatorstd::1::basic_string > >' requested here
struct node_raw: public node_base<Tree, node_raw<Tree, Data>, vector<noderaw<Tree, Data>, typename Tree::allocator_type> > {
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
/Users/jon/Downloads/st_tree-master/include/st_tree.h:127:22: note: in instantiation of template class 'st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basic_string >' requested here
typedef typename node_type::base_type node_base_type;
^
/Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:35:18: note: in instantiation of template class 'st_tree::treestd:: 1::basic_string<char, st_tree::raw, std::1::allocatorstd::1::basic_string >' requested here
tree t;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:22:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:434:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/config:549:24: note: template is declared here
template struct static_assert_test;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:105:
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:447:33: error: 'cs_iterator' is a protected member of 'st_tree::detail::node_base<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::1::basic_string >, st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basic_string >, std::__1::vector<st_tree::detail::node_raw<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, std::1::basicstring > , std::1::allocatorstd::1::basic_string > >'
typedef typename base_type::cs_iterator cs_iterator;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
/Users/jon/Downloads/st_tree-master/include/st_tree.h:127:22: note: in instantiation of template class 'st_tree::detail::node_raw<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::__1::basic_string >, std:: 1::basic_string >' requested here
typedef typename node_type::base_type node_base_type;
^
/Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:35:18: note: in instantiation of template class 'st_tree::treestd::1::basic_string<char, st_tree::raw, std:: 1::allocatorstd::1::basic_string >' requested here
tree t;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
In file included from /Users/jon/Downloads/st_tree-master/include/st_tree.h:105:
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:47:40: note: declared protected here
typedef typename cs_type::iterator cs_iterator;
^
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:448:33: error: 'cs_const_iterator' is a protected member of 'st_tree::detail::node_base<st_tree::tree<std:: 1::basic_string, st_tree::raw, std::1::allocatorstd::1::basic_string >, st_tree::detail::node_raw<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::1::basic_string >, std::__1::basic_string >, std:: 1::vector<st_tree::detail::node_raw<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::1::basic_string >, std::__1::basic_string > *, std:: 1::allocatorstd::1::basic_string > >'
typedef typename base_type::cs_const_iterator cs_const_iterator;
^
/Users/jon/Downloads/st_tree-master/include/st_tree_nodes.h:48:46: note: declared protected here
typedef typename cs_type::const_iterator cs_const_iterator;
^
In file included from /Users/jon/Downloads/st_tree-master/examples/x06_graft.cpp:28:
/Users/jon/Downloads/st_tree-master/include/st_tree.h:136:33: error: no type named 'bf_iterator' in 'st_tree::detail::node_raw<st_tree::tree<std::1::basic_string, st_tree::raw, std:: 1::allocatorstd::__1::basic_string >, std:: 1::basic_string >'
typedef typename node_type::bf_iterator iterator;