https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81507
Bug ID: 81507 Summary: map header kills variant of vectors Product: gcc Version: 7.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: benni.buch at gmail dot com Target Milestone: --- I ran into a very strange bug: #include <variant> #include <vector> #include <map> // must include map to trigger the error!!! template < typename A, typename B > void apply(A const&, B const&){} int main(){ auto value = std::variant< std::vector< int >, std::vector< short > >(); std::visit([](auto const& v){ apply(v, 0ul); // std::tuple_size<long unsigned int> is incomplete }, value); } $ g++-7.1 -std=c++1z -o main gcc_variant_bug.cpp In file included from /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/bits/node_handle.h:40:0, from /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/bits/stl_tree.h:72, from /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/map:60, from gcc_variant_bug.cpp:4: /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/tuple: In instantiation of 'constexpr const size_t std::tuple_size_v<long unsigned int>': /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/tuple:1670:44: required from 'constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&) [with _Fn = const std::vector<int>&; _Tuple = long unsigned int]' gcc_variant_bug.cpp:14:8: required from 'main()::<lambda(const auto:1&)> [with auto:1 = std::vector<int>]' /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/variant:1236:44: required from 'constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...) [with _Visitor = main()::<lambda(const auto:1&)>; _Variants = {std::variant<std::vector<int, std::allocator<int> >, std::vector<short int, std::allocator<short int> > >&}]' gcc_variant_bug.cpp:15:10: required from here /home/bebuch/media/programme/gcc-7/include/c++/7.1.1/tuple:1271:29: error: incomplete type 'std::tuple_size<long unsigned int>' used in nested name specifier inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; ^~~~~~~~~~~~ $ g++-7.1 --version g++-7.1 (GCC) 7.1.1 20170509 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. I'm not quiet sure if it is a bug in the library or in the compiler frontend, but since the header map is involved, I suppose it's in the library.