-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Description
Describe the issue
Hashmap containers are unable to contain recursive types on MSVC when using /Zc:__cplusplus.
This works on GCC 15.2.1 and Clang 20.1.8.
/opt/msvc/bin/x64/cl -Iabsl_node_hash_map_test.exe.p -I. -I.. -I../subprojects/googletest-1.15.2/googletest/include -Isubprojects/googletest-1.15.2/googletest -I../subprojects/googletest-1.15.2/googletest -I../subprojects/googletest-1.15.2/googlemock/include -Isubprojects/googletest-1.15.2/googlemock -I../subprojects/googletest-1.15.2/googlemock -DNDEBUG /MD /nologo /showIncludes /utf-8 /Zc:__cplusplus /W3 /EHsc /std:c++20 /permissive- /O1 /Gw /Zi /D_CRT_SECURE_NO_WARNINGS /D_ENABLE_EXTENDED_ALIGNED_STORAGE /D_SCL_SECURE_NO_WARNINGS /bigobj /wd4005 /wd4068 /wd4180 /wd4503 /wd4800 -DNOMINMAX -DWIN32_LEAN_AND_MEAN /wd4018 /wd4101 /wd4244 /wd4267 /wd4503 /wd4996 /Fdabsl_node_hash_map_test.exe.p/absl_container_node_hash_map_test.cc.pdb /Foabsl_node_hash_map_test.exe.p/absl_container_node_hash_map_test.cc.obj /c ../absl/container/node_hash_map_test.cc
/opt/msvc/vc/tools/msvc/14.44.35207/include/utility(473): error C2079: 'std::pair<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree>::second' uses undefined struct 'absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree'
/opt/msvc/vc/tools/msvc/14.44.35207/include/utility(473): note: the template instantiation context (the oldest one first) is
../absl/container/node_hash_map_test.cc(131): note: see reference to class template instantiation 'absl::lts_20250814::node_hash_map<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree,absl::lts_20250814::hash_internal::Hash<T>,std::equal_to<T>,std::allocator<std::pair<const Key,Value>>>' being compiled
with
[
T=int,
Key=int,
Value=absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree
]
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/container/node_hash_map.h(129): note: see reference to class template instantiation 'absl::lts_20250814::container_internal::raw_hash_map<absl::lts_20250814::container_internal::NodeHashMapPolicy<Key,Value>,Hash,Eq,Alloc>' being compiled
with
[
Key=int,
Value=absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree,
Hash=absl::lts_20250814::hash_internal::Hash<int>,
Eq=std::equal_to<int>,
Alloc=std::allocator<std::pair<const int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree>>
]
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/container/internal/raw_hash_map.h(35): note: see reference to class template instantiation 'absl::lts_20250814::container_internal::raw_hash_set<Policy,Hash,Eq,Alloc>' being compiled
with
[
Policy=absl::lts_20250814::container_internal::NodeHashMapPolicy<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree>,
Hash=absl::lts_20250814::hash_internal::Hash<int>,
Eq=std::equal_to<int>,
Alloc=std::allocator<std::pair<const int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree>>
]
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/container/internal/raw_hash_set.h(2470): note: see reference to class template instantiation 'absl::lts_20250814::type_traits_internal::IsOwner<std::pair<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree>>' being compiled
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/meta/type_traits.h(480): note: see reference to class template instantiation 'std::pair<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_AssignRecursive_Test::TestBody::Tree>' being compiled
/opt/msvc/vc/tools/msvc/14.44.35207/include/utility(473): error C2079: 'std::pair<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType>::second' uses undefined struct 'absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType'
/opt/msvc/vc/tools/msvc/14.44.35207/include/utility(473): note: the template instantiation context (the oldest one first) is
../absl/container/node_hash_map_test.cc(339): note: see reference to class template instantiation 'absl::lts_20250814::node_hash_map<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType,absl::lts_20250814::hash_internal::Hash<T>,std::equal_to<T>,std::allocator<std::pair<const Key,Value>>>' being compiled
with
[
T=int,
Key=int,
Value=absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType
]
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/container/node_hash_map.h(129): note: see reference to class template instantiation 'absl::lts_20250814::container_internal::raw_hash_map<absl::lts_20250814::container_internal::NodeHashMapPolicy<Key,Value>,Hash,Eq,Alloc>' being compiled
with
[
Key=int,
Value=absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType,
Hash=absl::lts_20250814::hash_internal::Hash<int>,
Eq=std::equal_to<int>,
Alloc=std::allocator<std::pair<const int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType>>
]
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/container/internal/raw_hash_map.h(35): note: see reference to class template instantiation 'absl::lts_20250814::container_internal::raw_hash_set<Policy,Hash,Eq,Alloc>' being compiled
with
[
Policy=absl::lts_20250814::container_internal::NodeHashMapPolicy<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType>,
Hash=absl::lts_20250814::hash_internal::Hash<int>,
Eq=std::equal_to<int>,
Alloc=std::allocator<std::pair<const int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType>>
]
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/container/internal/raw_hash_set.h(2470): note: see reference to class template instantiation 'absl::lts_20250814::type_traits_internal::IsOwner<std::pair<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType>>' being compiled
/home/mochaa/ghq/github.com/abseil/abseil-cpp/absl/meta/type_traits.h(480): note: see reference to class template instantiation 'std::pair<int,absl::lts_20250814::container_internal::`anonymous-namespace'::NodeHashMap_RecursiveTypeCompiles_Test::TestBody::RecursiveType>' being compiled
Steps to reproduce the problem
- Install MSVC 14.44.35207 x64 + Windows SDK 10.0.26100.0
- Compile absl with CMake option
-DABSL_BUILD_TESTING=ONand extra CXXFLAGS/Zc:__cplusplus. - See compilation error on
absl/container/{flat,node}_hash_map_test.cc
What version of Abseil are you using?
Both reproducible on:
- current master:
9dc9586effb94a41f9471de61278bfcd62964da1 - Abseil LTS 20250814.0
What operating system and version are you using?
(This section is mostly unrelated to the problem.)
Fedora Linux (kernel 6.17.0-0.rc4.36.fc44, glibc 2.42.9000, libstdc++ 15.2.1)
Wine 10.14 (Staging) + msvc-wine cb78cc0bc91a9e3da69989b76b99d6f44a7d1a69
What compiler and version are you using?
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35215 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
What build system are you using?
both reproducible on:
- cmake version 4.0.0-rc4
- bazel 8.3.1
Additional context
Initially found when porting to meson: mesonbuild/wrapdb#2070 (comment)
I wish to submit the port here once it reaches feature parity with CMake.
Features missing:
- Generate pkgconfig files
- Offer monolithic DLL build
- Actually ensure
linkstaticto satisfy tests requiring them (optional, this is a bazel thing)
Metadata
Metadata
Assignees
Labels
No labels