Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail to compile (GCC 14) #50

Open
musicinmybrain opened this issue Jan 15, 2025 · 2 comments
Open

Tests fail to compile (GCC 14) #50

musicinmybrain opened this issue Jan 15, 2025 · 2 comments

Comments

@musicinmybrain
Copy link
Contributor

Using GCC 14.2.1 in Fedora 41, the current master 7503c54 fails to compile:

$ git clone https://github.com/martinmoene/variant-lite.git
$ cd variant-lite
$ cmake -S. -Bbuild
$ cmake --build build --verbose
[…]
[ 91%] Building CXX object test/CMakeFiles/variant-lite-cpp17.t.dir/variant.t.cpp.o
cd /home/ben/src/forks/variant-lite/build/test && /usr/bin/c++ -Dvariant_CONFIG_SELECT_VARIANT=variant_VARIANT_DEFAULT -I/home/ben/src/forks/variant-lite/test/. -I/home/ben/src/forks/variant-lite/include -isystem /home/ben/src/forks/variant-lite/test/lest -Wall -Wextra -Wconversion -Wsign-conversion -Wno-missing-braces -fno-elide-constructors -std=c++17 -MD -MT test/CMakeFiles/variant-lite-cpp17.t.dir/variant.t.cpp.o -MF CMakeFiles/variant-lite-cpp17.t.dir/variant.t.cpp.o.d -o CMakeFiles/variant-lite-cpp17.t.dir/variant.t.cpp.o -c /home/ben/src/forks/variant-lite/test/variant.t.cpp
/home/ben/src/forks/variant-lite/test/variant.t.cpp: In function ‘void __lest_function__520(lest::env&)’:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:525:43: error: no matching function for call to ‘std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::variant(int&)’
  525 |     variant<double, std::string> var1(  i );
      |                                           ^
In file included from /home/ben/src/forks/variant-lite/include/nonstd/variant.hpp:214,
                 from /home/ben/src/forks/variant-lite/test/variant-main.t.hpp:13,
                 from /home/ben/src/forks/variant-lite/test/variant.t.cpp:8:
/usr/include/c++/14/variant:1487:9: note: candidate: ‘template<long unsigned int _Np, class _Up, class ... _Args, class _Tp, class> constexpr std::variant<_Types>::variant(std::in_place_index_t<_Np>, std::initializer_list<_Up>, _Args&& ...) [with long unsigned int _Np = _Np; _Args = _Up; _Tp = {_Args ...}; <template-parameter-2-5> = _Tp; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1487 |         variant(in_place_index_t<_Np>, initializer_list<_Up> __il,
      |         ^~~~~~~
/usr/include/c++/14/variant:1487:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/variant:1477:9: note: candidate: ‘template<long unsigned int _Np, class ... _Args, class _Tp, class> constexpr std::variant<_Types>::variant(std::in_place_index_t<_Np>, _Args&& ...) [with long unsigned int _Np = _Np; _Args = {_Args ...}; <template-parameter-2-4> = _Tp; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1477 |         variant(in_place_index_t<_Np>, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/variant:1477:9: note:   template argument deduction/substitution failed:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:525:43: note:   mismatched types ‘std::in_place_index_t<_Idx>’ and ‘int’
  525 |     variant<double, std::string> var1(  i );
      |                                           ^
/usr/include/c++/14/variant:1467:9: note: candidate: ‘template<class _Tp, class _Up, class ... _Args, class> constexpr std::variant<_Types>::variant(std::in_place_type_t<_Tp>, std::initializer_list<_Up>, _Args&& ...) [with _Up = _Tp; _Args = _Up; <template-parameter-2-4> = {_Args ...}; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1467 |         variant(in_place_type_t<_Tp>, initializer_list<_Up> __il,
      |         ^~~~~~~
/usr/include/c++/14/variant:1467:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/variant:1457:9: note: candidate: ‘template<class _Tp, class ... _Args, class> constexpr std::variant<_Types>::variant(std::in_place_type_t<_Tp>, _Args&& ...) [with _Args = _Tp; <template-parameter-2-3> = {_Args ...}; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1457 |         variant(in_place_type_t<_Tp>, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/variant:1457:9: note:   template argument deduction/substitution failed:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:525:43: note:   mismatched types ‘std::in_place_type_t<_Tp>’ and ‘int’
  525 |     variant<double, std::string> var1(  i );
      |                                           ^
/usr/include/c++/14/variant:1447:9: note: candidate: ‘template<class _Tp, class, class, class _Tj, class> constexpr std::variant<_Types>::variant(_Tp&&) [with <template-parameter-2-2> = _Tp; _Tj = <template-parameter-1-2>; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1447 |         variant(_Tp&& __t)
      |         ^~~~~~~
/usr/include/c++/14/variant:1447:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/variant: In substitution of ‘template<class ... _Types> template<class _Tp, class> using std::variant<_Types>::__accepted_type = std::variant<_Types>::__to_type<((long unsigned int)__accepted_index<_Tp>)> [with _Tp = int&; <template-parameter-2-2> = void; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’:
/usr/include/c++/14/variant:1443:9:   required from here
 1443 |                typename _Tj = __accepted_type<_Tp&&>,
      |                ^~~~~~~~
/usr/include/c++/14/variant:1403:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
 1403 |         using __accepted_type = __to_type<__accepted_index<_Tp>>;
      |               ^~~~~~~~~~~~~~~
/usr/include/c++/14/variant:1430:9: note: candidate: ‘template<class _Tp0, class> constexpr std::variant<_Types>::variant() [with <template-parameter-2-2> = _Tp0; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1430 |         variant() noexcept(is_nothrow_default_constructible_v<__to_type<0>>)
      |         ^~~~~~~
/usr/include/c++/14/variant:1430:9: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/variant:1435:7: note: candidate: ‘std::variant<_Types>::variant(std::variant<_Types>&&) [with _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1435 |       variant(variant&&) = default;
      |       ^~~~~~~
/usr/include/c++/14/variant:1435:15: note:   no known conversion for argument 1 from ‘int’ to ‘std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&&’
 1435 |       variant(variant&&) = default;
      |               ^~~~~~~~~
/usr/include/c++/14/variant:1434:7: note: candidate: ‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1434 |       variant(const variant& __rhs) = default;
      |       ^~~~~~~
/usr/include/c++/14/variant:1434:30: note:   no known conversion for argument 1 from ‘int’ to ‘const std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&’
 1434 |       variant(const variant& __rhs) = default;
      |               ~~~~~~~~~~~~~~~^~~~~
/home/ben/src/forks/variant-lite/test/variant.t.cpp:526:43: error: no matching function for call to ‘std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::variant(int)’
  526 |     variant<double, std::string> var2(  7 );
      |                                           ^
/usr/include/c++/14/variant:1487:9: note: candidate: ‘template<long unsigned int _Np, class _Up, class ... _Args, class _Tp, class> constexpr std::variant<_Types>::variant(std::in_place_index_t<_Np>, std::initializer_list<_Up>, _Args&& ...) [with long unsigned int _Np = _Np; _Args = _Up; _Tp = {_Args ...}; <template-parameter-2-5> = _Tp; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1487 |         variant(in_place_index_t<_Np>, initializer_list<_Up> __il,
      |         ^~~~~~~
/usr/include/c++/14/variant:1487:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/variant:1477:9: note: candidate: ‘template<long unsigned int _Np, class ... _Args, class _Tp, class> constexpr std::variant<_Types>::variant(std::in_place_index_t<_Np>, _Args&& ...) [with long unsigned int _Np = _Np; _Args = {_Args ...}; <template-parameter-2-4> = _Tp; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1477 |         variant(in_place_index_t<_Np>, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/variant:1477:9: note:   template argument deduction/substitution failed:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:526:43: note:   mismatched types ‘std::in_place_index_t<_Idx>’ and ‘int’
  526 |     variant<double, std::string> var2(  7 );
      |                                           ^
/usr/include/c++/14/variant:1467:9: note: candidate: ‘template<class _Tp, class _Up, class ... _Args, class> constexpr std::variant<_Types>::variant(std::in_place_type_t<_Tp>, std::initializer_list<_Up>, _Args&& ...) [with _Up = _Tp; _Args = _Up; <template-parameter-2-4> = {_Args ...}; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1467 |         variant(in_place_type_t<_Tp>, initializer_list<_Up> __il,
      |         ^~~~~~~
/usr/include/c++/14/variant:1467:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/variant:1457:9: note: candidate: ‘template<class _Tp, class ... _Args, class> constexpr std::variant<_Types>::variant(std::in_place_type_t<_Tp>, _Args&& ...) [with _Args = _Tp; <template-parameter-2-3> = {_Args ...}; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1457 |         variant(in_place_type_t<_Tp>, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/variant:1457:9: note:   template argument deduction/substitution failed:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:526:43: note:   mismatched types ‘std::in_place_type_t<_Tp>’ and ‘int’
  526 |     variant<double, std::string> var2(  7 );
      |                                           ^
/usr/include/c++/14/variant:1447:9: note: candidate: ‘template<class _Tp, class, class, class _Tj, class> constexpr std::variant<_Types>::variant(_Tp&&) [with <template-parameter-2-2> = _Tp; _Tj = <template-parameter-1-2>; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1447 |         variant(_Tp&& __t)
      |         ^~~~~~~
/usr/include/c++/14/variant:1447:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/variant: In substitution of ‘template<class ... _Types> template<class _Tp, class> using std::variant<_Types>::__accepted_type = std::variant<_Types>::__to_type<((long unsigned int)__accepted_index<_Tp>)> [with _Tp = int&&; <template-parameter-2-2> = void; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’:
/usr/include/c++/14/variant:1443:9:   required from here
 1443 |                typename _Tj = __accepted_type<_Tp&&>,
      |                ^~~~~~~~
/usr/include/c++/14/variant:1403:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
 1403 |         using __accepted_type = __to_type<__accepted_index<_Tp>>;
      |               ^~~~~~~~~~~~~~~
/usr/include/c++/14/variant:1430:9: note: candidate: ‘template<class _Tp0, class> constexpr std::variant<_Types>::variant() [with <template-parameter-2-2> = _Tp0; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1430 |         variant() noexcept(is_nothrow_default_constructible_v<__to_type<0>>)
      |         ^~~~~~~
/usr/include/c++/14/variant:1430:9: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/variant:1435:7: note: candidate: ‘std::variant<_Types>::variant(std::variant<_Types>&&) [with _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1435 |       variant(variant&&) = default;
      |       ^~~~~~~
/usr/include/c++/14/variant:1435:15: note:   no known conversion for argument 1 from ‘int’ to ‘std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&&’
 1435 |       variant(variant&&) = default;
      |               ^~~~~~~~~
/usr/include/c++/14/variant:1434:7: note: candidate: ‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1434 |       variant(const variant& __rhs) = default;
      |       ^~~~~~~
/usr/include/c++/14/variant:1434:30: note:   no known conversion for argument 1 from ‘int’ to ‘const std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&’
 1434 |       variant(const variant& __rhs) = default;
      |               ~~~~~~~~~~~~~~~^~~~~
/home/ben/src/forks/variant-lite/test/variant.t.cpp: In function ‘void __lest_function__538(lest::env&)’:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:544:45: error: no matching function for call to ‘std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::variant(__lest_function__538(lest::env&)::Int)’
  544 |     variant<double, std::string> var( Int{} );
      |                                             ^
/usr/include/c++/14/variant:1487:9: note: candidate: ‘template<long unsigned int _Np, class _Up, class ... _Args, class _Tp, class> constexpr std::variant<_Types>::variant(std::in_place_index_t<_Np>, std::initializer_list<_Up>, _Args&& ...) [with long unsigned int _Np = _Np; _Args = _Up; _Tp = {_Args ...}; <template-parameter-2-5> = _Tp; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1487 |         variant(in_place_index_t<_Np>, initializer_list<_Up> __il,
      |         ^~~~~~~
/usr/include/c++/14/variant:1487:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/variant:1477:9: note: candidate: ‘template<long unsigned int _Np, class ... _Args, class _Tp, class> constexpr std::variant<_Types>::variant(std::in_place_index_t<_Np>, _Args&& ...) [with long unsigned int _Np = _Np; _Args = {_Args ...}; <template-parameter-2-4> = _Tp; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1477 |         variant(in_place_index_t<_Np>, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/variant:1477:9: note:   template argument deduction/substitution failed:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:544:45: note:   ‘__lest_function__538(lest::env&)::Int’ is not derived from ‘std::in_place_index_t<_Idx>’
  544 |     variant<double, std::string> var( Int{} );
      |                                             ^
/usr/include/c++/14/variant:1467:9: note: candidate: ‘template<class _Tp, class _Up, class ... _Args, class> constexpr std::variant<_Types>::variant(std::in_place_type_t<_Tp>, std::initializer_list<_Up>, _Args&& ...) [with _Up = _Tp; _Args = _Up; <template-parameter-2-4> = {_Args ...}; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1467 |         variant(in_place_type_t<_Tp>, initializer_list<_Up> __il,
      |         ^~~~~~~
/usr/include/c++/14/variant:1467:9: note:   candidate expects at least 2 arguments, 1 provided
/usr/include/c++/14/variant:1457:9: note: candidate: ‘template<class _Tp, class ... _Args, class> constexpr std::variant<_Types>::variant(std::in_place_type_t<_Tp>, _Args&& ...) [with _Args = _Tp; <template-parameter-2-3> = {_Args ...}; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1457 |         variant(in_place_type_t<_Tp>, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/variant:1457:9: note:   template argument deduction/substitution failed:
/home/ben/src/forks/variant-lite/test/variant.t.cpp:544:45: note:   ‘__lest_function__538(lest::env&)::Int’ is not derived from ‘std::in_place_type_t<_Tp>’
  544 |     variant<double, std::string> var( Int{} );
      |                                             ^
/usr/include/c++/14/variant:1447:9: note: candidate: ‘template<class _Tp, class, class, class _Tj, class> constexpr std::variant<_Types>::variant(_Tp&&) [with <template-parameter-2-2> = _Tp; _Tj = <template-parameter-1-2>; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1447 |         variant(_Tp&& __t)
      |         ^~~~~~~
/usr/include/c++/14/variant:1447:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/variant: In substitution of ‘template<class ... _Types> template<class _Tp, class> using std::variant<_Types>::__accepted_type = std::variant<_Types>::__to_type<((long unsigned int)__accepted_index<_Tp>)> [with _Tp = __lest_function__538(lest::env&)::Int&&; <template-parameter-2-2> = void; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’:
/usr/include/c++/14/variant:1443:9:   required from here
 1443 |                typename _Tj = __accepted_type<_Tp&&>,
      |                ^~~~~~~~
/usr/include/c++/14/variant:1403:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
 1403 |         using __accepted_type = __to_type<__accepted_index<_Tp>>;
      |               ^~~~~~~~~~~~~~~
/usr/include/c++/14/variant:1430:9: note: candidate: ‘template<class _Tp0, class> constexpr std::variant<_Types>::variant() [with <template-parameter-2-2> = _Tp0; _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1430 |         variant() noexcept(is_nothrow_default_constructible_v<__to_type<0>>)
      |         ^~~~~~~
/usr/include/c++/14/variant:1430:9: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/variant:1435:7: note: candidate: ‘std::variant<_Types>::variant(std::variant<_Types>&&) [with _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1435 |       variant(variant&&) = default;
      |       ^~~~~~~
/usr/include/c++/14/variant:1435:15: note:   no known conversion for argument 1 from ‘__lest_function__538(lest::env&)::Int’ to ‘std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&&’
 1435 |       variant(variant&&) = default;
      |               ^~~~~~~~~
/usr/include/c++/14/variant:1434:7: note: candidate: ‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types = {double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
 1434 |       variant(const variant& __rhs) = default;
      |       ^~~~~~~
/usr/include/c++/14/variant:1434:30: note:   no known conversion for argument 1 from ‘__lest_function__538(lest::env&)::Int’ to ‘const std::variant<double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&’
 1434 |       variant(const variant& __rhs) = default;
      |               ~~~~~~~~~~~~~~~^~~~~
gmake[2]: *** [test/CMakeFiles/variant-lite-cpp17.t.dir/build.make:93: test/CMakeFiles/variant-lite-cpp17.t.dir/variant.t.cpp.o] Error 1
gmake[2]: Leaving directory '/home/ben/src/forks/variant-lite/build'
gmake[1]: *** [CMakeFiles/Makefile2:208: test/CMakeFiles/variant-lite-cpp17.t.dir/all] Error 2
gmake[1]: Leaving directory '/home/ben/src/forks/variant-lite/build'
gmake: *** [Makefile:146: all] Error 2 

If I git checkout v2.0.0 and try again, the result is similar.

@Titaniumtown
Copy link

I can reproduce on nix in the process of packaging it: NixOS/nixpkgs#372723

@musicinmybrain
Copy link
Contributor Author

In the package review for Fedora, Benson Muite pointed out that the tests only fail to compile in C++17 mode, so I’m working around this for the time being by hacking up test/CMakeLists.txt to pretend that C++17 mode is unavailable. At least that way I can still run the tests in C++98, C++11, and C++14 modes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants