-
Notifications
You must be signed in to change notification settings - Fork 37
clang - removing some compiler errors for clang #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…etails::StaticQueueBaseOptimised<T>), since we pass &array_[0] to Base's constructor This removes the following clang warning: warning: field 'array_' is uninitialized when used here
…s only parsed if boost is available)
|
The compilation (non-cross, i.e. desktop-target) on clang is working very well, when using libstdc++. sudo apt-get install clang # clang
git clone https://github.com/ajneu/embxx.git
cd embxx/
git checkout clang # special branch for clang (equivalent with this pull-request)
mkdir build
cd build
export CC=clang; export CXX=clang++
cmake ..
make -j4
make testBut when using clang with libc++ (see below), there are errors which I don't know how to remove. sudo apt-get install clang # clang
sudo apt-get install libc++-dev libc++abi-dev # libc++ (https://libcxx.llvm.org/)
git clone https://github.com/ajneu/embxx.git
cd embxx/
git checkout clang # special branch for clang (equivalent with this pull-request)
mkdir build
cd build
export CC=clang; export CXX=clang++
cmake -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi" ..
make -j4The errors are static_asserts here, and the output is the following: In file included from /tmp/embxx/build/module/driver/test/GenericTestRunner.cpp:23:
In file included from /tmp/embxx/module/driver/test/Generic.th:19:
/tmp/embxx/embxx/util/StaticFunction.h:421:5: error: static_assert failed "Wrong function invocation"
static_assert(!std::is_same<ThisType, DecayedFuncType>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/embxx/embxx/util/StaticFunction.h:196:5: note: in instantiation of function template specialization 'embxx::util::StaticFunction<void (),
24>::assignHandler<embxx::util::StaticFunction<void (), 24> &>' requested here
assignHandler(std::forward<TFunc>(func));
^
/usr/include/c++/v1/functional:2078:11: note: in instantiation of function template specialization 'embxx::util::StaticFunction<void (),
24>::StaticFunction<embxx::util::StaticFunction<void (), 24> &>' requested here
: __f_(_VSTD::forward<_Gp>(__f)),
^
/usr/include/c++/v1/functional:2187:12: note: in instantiation of function template specialization 'std::__1::__bind<embxx::util::StaticFunction<void (), 24>
&>::__bind<embxx::util::StaticFunction<void (), 24> &, void>' requested here
return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
^
/tmp/embxx/embxx/driver/Generic.h:199:26: note: in instantiation of function template specialization 'std::__1::bind<embxx::util::StaticFunction<void (), 24> &>' requested here
std::bind(handler_, args...));
^
/tmp/embxx/module/driver/test/Generic.th:76:12: note: in instantiation of function template specialization
'embxx::driver::Generic<GenericDriverTestSuite::Device<embxx::util::StaticFunction<void (), 24> >, embxx::util::EventLoop<132, embxx::device::test::EventLoopLock,
embxx::device::test::EventLoopCond>, void (), embxx::util::StaticFunction<void (), 24> >::setHandler<(lambda at /tmp/embxx/module/driver/test/Generic.th:77:9)>' requested here
driver.setHandler(
^In file included from /tmp/embxx/build/module/driver/test/GenericTestRunner.cpp:23:
In file included from /tmp/embxx/module/driver/test/Generic.th:19:
/tmp/embxx/embxx/util/StaticFunction.h:424:5: error: static_assert failed "Increase the TSize template argument of the StaticFucntion"
static_assert(sizeof(InvokerBoundType) <= StorageAreaSize,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/embxx/embxx/util/StaticFunction.h:421:5: error: static_assert failed "Wrong function invocation"
static_assert(!std::is_same<ThisType, DecayedFuncType>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/embxx/embxx/util/StaticFunction.h:196:5: note: in instantiation of function template specialization 'embxx::util::StaticFunction<void (char),
24>::assignHandler<embxx::util::StaticFunction<void (char), 24> &>' requested here
assignHandler(std::forward<TFunc>(func));
^
/usr/include/c++/v1/functional:2078:11: note: in instantiation of function template specialization 'embxx::util::StaticFunction<void (char),
24>::StaticFunction<embxx::util::StaticFunction<void (char), 24> &>' requested here
: __f_(_VSTD::forward<_Gp>(__f)),
^
/usr/include/c++/v1/functional:2187:12: note: in instantiation of function template specialization 'std::__1::__bind<embxx::util::StaticFunction<void (char), 24> &, char
&>::__bind<embxx::util::StaticFunction<void (char), 24> &, char &, void>' requested here
return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
^
/tmp/embxx/embxx/driver/Generic.h:199:26: note: in instantiation of function template specialization 'std::__1::bind<embxx::util::StaticFunction<void (char), 24> &, char &>' requested
here
std::bind(handler_, args...));
^
/tmp/embxx/module/driver/test/Generic.th:104:12: note: in instantiation of function template specialization
'embxx::driver::Generic<GenericDriverTestSuite::Device<embxx::util::StaticFunction<void (char), 24> >, embxx::util::EventLoop<132, embxx::device::test::EventLoopLock,
embxx::device::test::EventLoopCond>, void (char), embxx::util::StaticFunction<void (char), 24> >::setHandler<(lambda at /tmp/embxx/module/driver/test/Generic.th:105:9)>' requested
here
driver.setHandler(
^In file included from /tmp/embxx/build/module/driver/test/GenericTestRunner.cpp:23:
In file included from /tmp/embxx/module/driver/test/Generic.th:19:
/tmp/embxx/embxx/util/StaticFunction.h:424:5: error: static_assert failed "Increase the TSize template argument of the StaticFucntion"
static_assert(sizeof(InvokerBoundType) <= StorageAreaSize,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~It's rather strange... these static asserts. |
I've tried increasing |
|
Some investigation regarding the static_asserts here If you change the following lines, to this: std::cout << "\n"
"ThisType : " << typeid(ThisType).name() << "\n"
"DecayedFuncType : " << typeid(DecayedFuncType).name() << '\n';
std::cout << "InvokerBoundType: " << typeid(InvokerBoundType).name() << "\n"
"sizeof(InvokerBoundType): " << sizeof(InvokerBoundType) << "\n"
"StorageAreaSize : " << StorageAreaSize << std::endl;
// static_assert(!std::is_same<ThisType, DecayedFuncType>::value,
// "Wrong function invocation");
// static_assert(sizeof(InvokerBoundType) <= StorageAreaSize,
// "Increase the TSize template argument of the StaticFucntion");then one can compare using libstdc++ with libc++. Using libstdc++ export CC=clang; export CXX=clang++
cmake ..
reset # clear shell
make -j4
./module/driver/test/driver.GenericTest | c++filt -tThe output is: Using libc++ # clear build directory, then...
export CC=clang; export CXX=clang++
cmake -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi" ..
reset # clear shell
make -j4
./module/driver/test/driver.GenericTest | c++filt -tThe output is: It also segfaults as can be seen with gdb gdb -ex run ./module/driver/test/driver.GenericTestoutputs or with clang's debugger lldb ( lldb -o run ./module/driver/test/driver.GenericTestoutputs |
Hi Alex,
here is some initial work on getting embxx to compile with
clang-3.7andclang++-3.7.Errors are removed, but there are still some warnings left, that one should investigate.
So no need, for this to be merged just yet. You can just leave this pull-request open, as a base, for people to base their further work on, regarding issue #7
Edit: I should mention, that many of the errors removed, actually seem to be just working around limitations of clang. So g++ really does feel much more mature, at least for the time being.