test
test copied to clipboard
Clang warning generated by dataset grid operation in C++20 mode
Clang 10+ generates a warning in C++20 mode, even with no warnings explicitly enabled.
$ clang++ -std=c++20 -I/mnt/saturn/source/boost_1_72_0 -c -o main.o main.cpp
In file included from main.cpp:6:
In file included from /mnt/saturn/source/boost_1_72_0/boost/test/data/monomorphic.hpp:21:
/mnt/saturn/source/boost_1_72_0/boost/test/data/monomorphic/grid.hpp:93:56: warning: arithmetic between different enumeration types ('boost::unit_test::data::monomorphic::collection<const std::array<int, 2> &>::(anonymous enum at /mnt/saturn/source/boost_1_72_0/boost/test/data/monomorphic/collection.hpp:44:5)' and 'boost::unit_test::data::monomorphic::collection<const std::array<int, 3> &>::(anonymous enum at /mnt/saturn/source/boost_1_72_0/boost/test/data/monomorphic/collection.hpp:44:5)') is deprecated [-Wdeprecated-anon-enum-enum-conversion]
enum { arity = boost::decay<DataSet1>::type::arity + boost::decay<DataSet2>::type::arity };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:38: note: in instantiation of template class 'boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::collection<const std::array<int, 2> &>, boost::unit_test::data::monomorphic::collection<const std::array<int, 3> &>>' requested here
boost::unit_test::data::make(data1) * data2,
^
1 warning generated.
main.cpp
:
#define BOOST_TEST_MODULE foo
#include <boost/test/unit_test.hpp>
#include <array>
#include <boost/test/data/monomorphic.hpp>
#include <boost/test/data/test_case.hpp>
// data1 and data2 must be different types.
// Different-sized arrays does the trick.
constexpr auto data1 = std::array{1, 2};
constexpr auto data2 = std::array{1, 2, 3};
BOOST_DATA_TEST_CASE(foo,
boost::unit_test::data::make(data1) * data2,
val1, val2)
{
BOOST_TEST(val1 == val2);
}
$ clang++ --version
clang version 11.0.0-++20200414060218+d1a677cd33e-1~exp1~20200414040817.489
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
The warning pops in all versions of Boost back to 1.65 (so far as I can tell from Wandbox). To reproduce, just use Clang 10 or 11, and specify C++20 (or C++2a) mode.
Minimal code to trigger the same warning (in Godbolt for example):
enum { v1 };
enum { v2 };
enum { v3 = v1 + v2 };
note: introduced by Clang in https://reviews.llvm.org/D71576
Same issue in VS2019 16.6.2.