Skip to content

[Bug]: flat_hash_map with incomplete variant value fails to compile in MSVC and C++20 #1960

@briangreenery

Description

@briangreenery

Describe the issue

I built with ee47800 (the current commit as of opening this issue).

On MSVC 2022 17.14.18 (October 2025) and /std:c++20 the following code fails to compile with this output:
https://gist.github.com/briangreenery/08a64ec3a0d04d33d3d2eb292ad7456e

#include "absl/container/flat_hash_map.h"
#include "absl/types/variant.h"

struct A;
struct B;

using Any = absl::variant< A, B >;

struct B
{
    absl::flat_hash_map< int, Any > map;
};

This compiles successfully when building using C++17. Like #1930, the problem seems to be related to IsLifetimeBoundAssignmentFrom, since commenting that out allows it to build.

Steps to reproduce the problem

Try to build this code with /std:c++20

#include "absl/container/flat_hash_map.h"
#include "absl/types/variant.h"

struct A;
struct B;

using Any = absl::variant< A, B >;

struct B
{
    absl::flat_hash_map< int, Any > map;
};

What version of Abseil are you using?

ee47800

What operating system and version are you using?

Windows 22H2

What compiler and version are you using?

MSVC 2022 17.14.18 (October 2025)

What build system are you using?

cmake 3.26.6

Additional context

This is the compiler output:
https://gist.github.com/briangreenery/08a64ec3a0d04d33d3d2eb292ad7456e

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions