hana
hana copied to clipboard
BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA and BOOST_HANA_CONSTEXPR_CHECK
I tried to enable BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA once and see some errors when building with MSVC and /std:c++17.
I only investigated several failures and one of them seems to be source issue:
test\assert\constexpr.cpp
BOOST_HANA_CONSTEXPR_ASSERT(runtime_bool
runtime_bool isn't a constexpr function.
Looks that this macro is deliberately left as undefined, so this issue is just a FYI.
BTW, clang-cl rejects the following code in test_include\laws\foldable.hpp:
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_left(list(1), z, f),
f(z, 1)
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_left(list(1, '2'), z, f),
f(f(z, 1), '2')
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_left(list(1, '2', 3.3), z, f),
f(f(f(z, 1), '2'), 3.3)
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_left(list(1, '2', 3.3, 4.4f), z, f),
f(f(f(f(z, 1), '2'), 3.3), 4.4f)
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_right(list(1), z, f),
f(1, z)
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_right(list(1, '2'), z, f),
f(1, f('2', z))
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_right(list(1, '2', 3.3), z, f),
f(1, f('2', f(3.3, z)))
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
fold_right(list(1, '2', 3.3, 4.4f), z, f),
f(1, f('2', f(3.3, f(4.4f, z))))
));
BOOST_HANA_CONSTEXPR_CHECK(equal(
minimum(list(ord<33>{}, short{45}, long{46})),
ord<33>{}
));
I didn't dig deeper to see whether this is a source issue or a compiler issue, though.
Here is the list of other failed tests (from MSVC):
1>------ Build started: Project: example.misc.infinite_set, Configuration: Debug Win32 ------ 3>------ Build started: Project: test.basic_tuple.laws, Configuration: Debug Win32 ------ 4>------ Build started: Project: test.concept.sequence.iterable, Configuration: Debug Win32 ------ 6>------ Build started: Project: test.ext.boost.tuple.iterable, Configuration: Debug Win32 ------ 7>------ Build started: Project: test.ext.boost.tuple.monad_plus, Configuration: Debug Win32 ------ 8>------ Build started: Project: test.ext.boost.tuple.searchable, Configuration: Debug Win32 ------ 9>------ Build started: Project: test.ext.std.tuple.laws, Configuration: Debug Win32 ------ 10>------ Build started: Project: test.foldable.fold_left_mcd.iterable, Configuration: Debug Win32 ------ 11>------ Build started: Project: test.foldable.iterable_mcd.iterable, Configuration: Debug Win32 ------ 12>------ Build started: Project: test.foldable.unpack_mcd.iterable, Configuration: Debug Win32 ------ 13>------ Build started: Project: test.numeric.minus_mcd, Configuration: Debug Win32 ------ 14>------ Build started: Project: test.numeric.negate_mcd, Configuration: Debug Win32 ------ 15>------ Build started: Project: test.tuple.laws, Configuration: Debug Win32 ------
I didn't investigate the root cause of the failure or try them using clang-cl.
Regarding the issue mentioned in my second post, looks that 'Tracked' is used in 'injection_result' and 'integer' ('_constant' derives from 'integer'). However, 'Tracked' isn't a literal type and neither are the types containing it. See 'test_include\laws\base.hpp' and 'test_include\support\tracked.hpp' for details. This will fail the constexpr evaluation.
The issue in the following two projects are in 'test\numeric\main.hpp':
13>------ Build started: Project: test.numeric.minus_mcd, Configuration: Debug Win32 ------ 14>------ Build started: Project: test.numeric.negate_mcd, Configuration: Debug Win32 ------
The related code:
auto x = numeric(1);
auto y = numeric(2);
Looks that constexpr is missing on these two local variables.
The issue in the following three projects are caused by the fact that boost::tuples::tuple isn't literal type (it doesn't use constexpr):
6>------ Build started: Project: test.ext.boost.tuple.iterable, Configuration: Debug Win32 ------ 7>------ Build started: Project: test.ext.boost.tuple.monad_plus, Configuration: Debug Win32 ------ 8>------ Build started: Project: test.ext.boost.tuple.searchable, Configuration: Debug Win32 ------
In summary, there are 4 kinds of source issues exposed after changing BOOST_HANA_CONSTEXPR_ASSERT to BOOST_HANA_CONSTANT_ASSERT (it is implied by BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA, even though the issues are not related to constexpr lambda).
- Incorrect constant assertion on runtime condition test\assert\constexpr.cpp
- Tracked isn't a literal type test_include\laws\base.hpp
- Missing constexpr on local variables test\numeric\main.hpp
- boost::tuples::tuple isn't a literal type
Other failures are likely bugs in MSVC compiler, I'll log bugs to our bug database.
I should be able to reproduce this using any version of Clang that implements C++17 (constexpr lambdas). I'll take a look at this as soon as I get the time. Once that is fixed, I can add a Travis job that enables BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA
to make sure this configuration option works.