rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.12k stars 430 forks source link

Compiler error in unit tests on std::initializer_list #310

Closed damienhocking closed 3 years ago

damienhocking commented 3 years ago

In variant_sequential_view_test.cpp, line 238, there's a unit test for std::initializer_list. With gcc 9.3, compiling this test fails on lines 451 and 440 of variant_data_policy.h, with "error: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Werror=init-list-lifetime]". It's a warning treated as an error. Given what the test is doing, I'm not sure this is the end of the world. I can't think of a situation where I'd be assigning an initializer_list that way. The warning is right, it's trying to new an initializer_list when according to cppreference "The underlying array is not guaranteed to exist after the lifetime of the original initializer list object has ended."

Possibly this should really be treated as a warning in this particular case.

damienhocking commented 3 years ago

I'm going to close this, because the "add github actions workflow & disable gcc9 warnings" commit fixed it.