abseil / abseil/abseil-cpp

[Bug]: `flat_hash_map` incorrectly reports copyability

Offen
#1,862 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
18.1k
Forks
3.2k
Ø Merge
20 Std. 36 Min.
Gemergte PRs (30 T.)
1

Beschreibung

### Describe the issue

`std::is_copy_constructible_v>` is `true` even when `std::is_copy_constructible_v` is `false`.

### Steps to reproduce the problem

https://godbolt.org/z/M7M9bqG5c

### What version of Abseil are you using?

20250121.0

### What operating system and version are you using?

Tested on Ubuntu, MacOS.

### What compiler and version are you using?

Tested on both clang and gcc

### What build system are you using?

bazel 8.1.1

### Additional context

Being sfinae friendly here is pretty important because standard library containers expect it. In my case, I had a `std::vector>` where `B` was a wrapper around an `absl::flat_hash_map`. Calls to `emplace_back`, which was very confusing.

The workaround is to explicitly declare the copy/move constructors explicitly for my wrapper as delete/default respectively so the trait doesn't dig into the implementation.

FWIW, `std::unordered_map` seems to have the same problem in both libc++ and libstdc++. I don't know of anything in the standard that requires this behavior. Also because it's detectable, a change can in theory constitute an ABI break, so that's fun. I know Abseil doesn't care, but there's an interesting question about divergence from standard behavior here.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.