boostorg / boostorg/test

Clang warning generated by dataset grid operation in C++20 mode

Open
#268 2 comments 1 reaction 1 assignee Claimed by @raffienficiaud View on GitHub
branch
Dominant language
C++
Stars
213
Forks
149
Avg merge
18h 17m
Merged PRs (30d)
2

Description

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 &>::(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 &>::(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::type::arity + boost::decay::type::arity };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:38: note: in instantiation of template class 'boost::unit_test::data::monomorphic::grid &>, boost::unit_test::data::monomorphic::collection &>>' requested here
boost::unit_test::data::make(data1) * data2,
^
1 warning generated.
```

`main.cpp`:
```c++
#define BOOST_TEST_MODULE foo
#include

#include

#include
#include

// 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):

```c++
enum { v1 };
enum { v2 };

enum { v3 = v1 + v2 };
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.