mkoeppe/LiDIA

Port to clang 6

Closed this issue · 7 comments

/usr/local/opt/llvm/bin/clang++ -DHAVE_CONFIG_H   -I../../include -I../../src/base/include -I./../../src/base/include -I/Users/mkoeppe/w/latte/latte-distro/ntl_cxx11/build-no-latte/dest/include  -O3 -MT bytes_to_int_flag_generator.o -MD -MP -MF .deps/bytes_to_int_flag_generator.Tpo -c -o bytes_to_int_flag_generator.o `test -f '../../src/portability/bytes_to_int_flag_generator.cc' || echo './'`../../src/portability/bytes_to_int_flag_generator.cc
../../src/portability/bytes_to_int_flag_generator.cc:219:37: error: non-type template argument evaluates to 18446744073709551613, which cannot be
      narrowed to type 'int' [-Wc++11-narrowing]
    typedef typename is_zero::apply<sizeof(T) - size>::type type;
                                    ^
../../src/portability/bytes_to_int_flag_generator.cc:184:33: note: in instantiation of template class 'size_match<4>::apply<signed char>' requested
      here
    typedef typename predicate::template apply<elem_type>::type pred_result;
                                ^
../../src/portability/bytes_to_int_flag_generator.cc:227:36: note: in instantiation of template class 'find_in_list::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<4> >' requested here
    typedef typename find_in_list::apply<candidate_list, pred>::type type;
                                   ^
../../src/portability/bytes_to_int_flag_generator.cc:391:29: note: in instantiation of template class 'fitting_int_type::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, 4>' requested here
  typedef fitting_int_type::apply<int_list, 4>::type int32_type;
                            ^
../../src/portability/bytes_to_int_flag_generator.cc:219:37: error: non-type template argument evaluates to 18446744073709551614, which cannot be
      narrowed to type 'int' [-Wc++11-narrowing]
    typedef typename is_zero::apply<sizeof(T) - size>::type type;
                                    ^
../../src/portability/bytes_to_int_flag_generator.cc:184:33: note: in instantiation of template class 'size_match<4>::apply<short>' requested here
    typedef typename predicate::template apply<elem_type>::type pred_result;
                                ^
../../src/portability/bytes_to_int_flag_generator.cc:193:20: note: in instantiation of template class 'find_in_list::apply<type_node<short,
      type_node<int, type_node<long, none_t> > >, size_match<4> >' requested here
  typedef typename apply<next, predicate>::type type;
                   ^
../../src/portability/bytes_to_int_flag_generator.cc:186:22: note: in instantiation of template class 'find_in_list::aux<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<4>, false_t>' requested here
    typedef typename aux<list, predicate, pred_result>::type type;
                     ^
../../src/portability/bytes_to_int_flag_generator.cc:227:36: note: in instantiation of template class 'find_in_list::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<4> >' requested here
    typedef typename find_in_list::apply<candidate_list, pred>::type type;
                                   ^
../../src/portability/bytes_to_int_flag_generator.cc:391:29: note: in instantiation of template class 'fitting_int_type::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, 4>' requested here
  typedef fitting_int_type::apply<int_list, 4>::type int32_type;
                            ^
../../src/portability/bytes_to_int_flag_generator.cc:219:37: error: non-type template argument evaluates to 18446744073709551609, which cannot be
      narrowed to type 'int' [-Wc++11-narrowing]
    typedef typename is_zero::apply<sizeof(T) - size>::type type;
                                    ^
../../src/portability/bytes_to_int_flag_generator.cc:184:33: note: in instantiation of template class 'size_match<8>::apply<signed char>' requested
      here
    typedef typename predicate::template apply<elem_type>::type pred_result;
                                ^
../../src/portability/bytes_to_int_flag_generator.cc:227:36: note: in instantiation of template class 'find_in_list::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<8> >' requested here
    typedef typename find_in_list::apply<candidate_list, pred>::type type;
                                   ^
../../src/portability/bytes_to_int_flag_generator.cc:392:29: note: in instantiation of template class 'fitting_int_type::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, 8>' requested here
  typedef fitting_int_type::apply<int_list, 8>::type int64_type;
                            ^
../../src/portability/bytes_to_int_flag_generator.cc:219:37: error: non-type template argument evaluates to 18446744073709551610, which cannot be
      narrowed to type 'int' [-Wc++11-narrowing]
    typedef typename is_zero::apply<sizeof(T) - size>::type type;
                                    ^
../../src/portability/bytes_to_int_flag_generator.cc:184:33: note: in instantiation of template class 'size_match<8>::apply<short>' requested here
    typedef typename predicate::template apply<elem_type>::type pred_result;
                                ^
../../src/portability/bytes_to_int_flag_generator.cc:193:20: note: in instantiation of template class 'find_in_list::apply<type_node<short,
      type_node<int, type_node<long, none_t> > >, size_match<8> >' requested here
  typedef typename apply<next, predicate>::type type;
                   ^
../../src/portability/bytes_to_int_flag_generator.cc:186:22: note: in instantiation of template class 'find_in_list::aux<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<8>, false_t>' requested here
    typedef typename aux<list, predicate, pred_result>::type type;
                     ^
../../src/portability/bytes_to_int_flag_generator.cc:227:36: note: in instantiation of template class 'find_in_list::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<8> >' requested here
    typedef typename find_in_list::apply<candidate_list, pred>::type type;
                                   ^
../../src/portability/bytes_to_int_flag_generator.cc:392:29: note: in instantiation of template class 'fitting_int_type::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, 8>' requested here
  typedef fitting_int_type::apply<int_list, 8>::type int64_type;
                            ^
../../src/portability/bytes_to_int_flag_generator.cc:219:37: error: non-type template argument evaluates to 18446744073709551612, which cannot be
      narrowed to type 'int' [-Wc++11-narrowing]
    typedef typename is_zero::apply<sizeof(T) - size>::type type;
                                    ^
../../src/portability/bytes_to_int_flag_generator.cc:184:33: note: in instantiation of template class 'size_match<8>::apply<int>' requested here
    typedef typename predicate::template apply<elem_type>::type pred_result;
                                ^
../../src/portability/bytes_to_int_flag_generator.cc:193:20: note: in instantiation of template class 'find_in_list::apply<type_node<int,
      type_node<long, none_t> >, size_match<8> >' requested here
  typedef typename apply<next, predicate>::type type;
                   ^
../../src/portability/bytes_to_int_flag_generator.cc:186:22: note: in instantiation of template class 'find_in_list::aux<type_node<short,
      type_node<int, type_node<long, none_t> > >, size_match<8>, false_t>' requested here
    typedef typename aux<list, predicate, pred_result>::type type;
                     ^
../../src/portability/bytes_to_int_flag_generator.cc:193:20: note: in instantiation of template class 'find_in_list::apply<type_node<short,
      type_node<int, type_node<long, none_t> > >, size_match<8> >' requested here
  typedef typename apply<next, predicate>::type type;
                   ^
../../src/portability/bytes_to_int_flag_generator.cc:186:22: note: in instantiation of template class 'find_in_list::aux<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<8>, false_t>' requested here
    typedef typename aux<list, predicate, pred_result>::type type;
                     ^
../../src/portability/bytes_to_int_flag_generator.cc:227:36: note: in instantiation of template class 'find_in_list::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, size_match<8> >' requested here
    typedef typename find_in_list::apply<candidate_list, pred>::type type;
                                   ^
../../src/portability/bytes_to_int_flag_generator.cc:392:29: note: in instantiation of template class 'fitting_int_type::apply<type_node<signed char,
      type_node<short, type_node<int, type_node<long, none_t> > > >, 8>' requested here
  typedef fitting_int_type::apply<int_list, 8>::type int64_type;
                            ^

Yes, I was going to submit same kind of error log (on FreeBSD 12), but it looks as if you already know.
As clang 6.0.1 is the default compiler on such a system, it's a show-stopper of sorts.

Pull requests are welcome

Do you understand the 1st error message non-type template argument evaluates to 18446744073709551613, which cannot be narrowed to type 'int' ?

Note that maxint on x86_64 is M=9223372036854775807=2^63-1, whereas that crazy number is 2M-1. In Python2:

>>> import sys
>>> C=18446744073709551613
>>> M=sys.maxint
>>> 2*M-C
1L

This smells of a compiler bug to me. What should be the actual value, roughly? In single/double digits?

Perhaps a better question is whether that portability/bytes_to_int_flag_generator.cc is meant to cover for missing features C++, whereas in C++1x they are already present?

I'd removed all the traces of bytes_to_int_flag_generator in library/base/Makefile.in - this merely leaves already generated header in include/ - and this header is the same as generated by gcc6 on x86_64.
This hack together with #2 makes clang 6 work.

So the problem is to either fix portability/bytes_to_int_flag_generator.cc or sort out whether this generated header is needed (it might be only needed for very old C++ compilers...).

OK. I can now reproduce this with the new Travis scripts.

Fixed in c73bb21.