Open yurivict opened 6 years ago
@barche Jan, are you able to fix these? The FreeBSD port for k3d has been deleted some while ago. I am trying to restore it now. But it doesn't build with clang-40. Are you able to fix all clang-40 build errors?
Thanks, Yuri
Hi Yuri,
Sorry for the slow reply, I haven't build K-3D using clang for some years. I don't have a freeBSD system to test this on, but I could try building on my Mac and see if I can reproduce this. I think in this case adding explicit casts is the solution, e.g.
GLfloat color[] = { static_cast<float>(Color.red), static_cast<float>(Color.green), static_cast<float>(Color.blue), static_cast<float>(Alpha) };
Yes, this would have been great if you could fix clang issues on any system. The rest of the differences if any shouldn't be too hard to accommodate.
OK, so it builds using clang 5 on Linux now, hopefully this also gets you further on FreeBSD!
It still breaks for me here:
In file included from /usr/local/include/boost/gil/gil_all.hpp:26:
/usr/local/include/boost/gil/channel_algorithm.hpp:54:85: error: non-type template argument evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]
struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,-1> {};
^
/usr/local/include/boost/gil/channel_algorithm.hpp:204:19: note: in instantiation of template class 'boost::gil::detail::unsigned_integral_max_value<unsigned long>' requested here
if (src > unsigned_integral_max_value<uintmax_t>::value - div2)
^
Also, you should remove all register
keywords. Latest developments in compiles rendered it useless, and it only causes warnings now.
clang-5.0.0
Is that the complete error? It is situated completely in boost, on my system it selects the gil
library included in K-3D and then it compiles.
This line https://github.com/K-3D/k3d/blob/master/k3dsdk/bitmap.h#L36 includes gil_all.hpp that isn't in the project.
It can't use the include from the pre-installed boost, but override only the gil
package. This is just too convoluted. :-)
Actually, what is added is an extension to gil, so files from the system boost are still needed. I can't reproduce this error on my linux system, can you please post the full error, including the location in the K-3D code that triggers this? If there is no instantiation in K-3D, I guess this is really a bug in boost, I'm using version 1.66 but the referred lines are the same.
Here is one full instance of this error:
--- k3dsdk/CMakeFiles/k3dsdk.dir/utility_gl.cpp.o ---
In file included from /usr/ports/graphics/k3d/work/k3d-7111d0e/k3dsdk/utility_gl.cpp:37:
In file included from /usr/ports/graphics/k3d/work/k3d-7111d0e/k3dsdk/utility_gl.h:28:
In file included from /usr/ports/graphics/k3d/work/k3d-7111d0e/k3dsdk/bitmap.h:36:
In file included from /usr/local/include/boost/gil/gil_all.hpp:26:
/usr/local/include/boost/gil/channel_algorithm.hpp:54:85: error: non-type template argument evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]
struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,-1> {};
^
/usr/local/include/boost/gil/channel_algorithm.hpp:204:19: note: in instantiation of template class 'boost::gil::detail::unsigned_integral_max_value<unsigned long>' requested here
if (src > unsigned_integral_max_value<uintmax_t>::value - div2)
^
OK, so it appears there is no instantiation happening from K-3D. Can you try compiling and posting the output of the following test program:
#include <iostream>
#include <typeinfo>
#include <boost/gil/gil_all.hpp>
int main()
{
std::cout << typeid(boost::uintmax_t).name() << std::endl;
std::cout << typeid(uint64_t).name() << std::endl;
return 0;
}
I compiled it with
clang++ -o test test.cpp
$ ./test
m
m
Can you try adding the following in bitmap.h
, just before the existing channel_converter_unsigned
:
template <> struct channel_converter_unsigned<bits32f,uintmax_t> : public std::unary_function<bits32f,bits32f>
{
uintmax_t operator()(bits32f x) const { return uintmax_t(static_cast<float>(x)); }
};
With channel_converter_unsigned<bits32f,uintmax_t>
it breaks the same way.
Well then, if the error has absolutely no indication of what part of K-3D is causing this, then I'm out of ideas...
To me, it looks like boost tries to instantiate its own template with the wrong argument: for mpl::integral_c
, the base of unsigned_integral_max_value
, it supplies -1
when a type is expected. But since they both are in the boost headers, it looks like an internal boost error.
Yes, you could try replacing the -1
with static_cast<UnsignedIntegralChannel>(-1)
in your boost header, see how far that gets us. If it works that way, it's probably best to submit a bug report to Boost
Substituting with static_cast<UnsignedIntegralChannel>(-1)
indeed helped.
I submitted the ticket to boost: https://svn.boost.org/trac10/ticket/13397
FYI, this issue has been fixed in GIL released in Boost 1.68 https://github.com/boostorg/gil/commit/18eacb424baf69852bb24858e1b3a5c86e1f9033 So, the https://svn.boost.org/trac10/ticket/13397 has just been closed.
Thank you for reporting the issue anyway.