abseil / abseil/abseil-cpp

absl::btree_map: constexpr variable 'kFirst' must be initialized by a constant expression

Aperta
#729 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C++
Stelle
18.1k
Fork
3.2k
Merge medio
20h 36m
PR unite (30g)
1

Descrizione

Hi I am receiving a compiler error use of aseil::btree_map running it through clang.

absl/container/internal/container_memory.h:259:27: error: constexpr variable 'kFirst' must be initialized by a constant expression [clang-diagnostic-error]
static constexpr size_t kFirst = offsetof(Pair, first);

The offending code is:
`
template
struct OffsetOf::type> {
static constexpr size_t kFirst = offsetof(Pair, first);
static constexpr size_t kSecond = offsetof(Pair, second);
};
`

And seems to be caused by the use of 'offsetof', which makes use of reinterpret_cast:
`#define offsetof(s,m) ((::size_t)&reinterpret_cast((((s*)0)->m)))`

Which is not allowed in a constexpr expression.

Any ideas how to fix this?

The abseil sdk is from 2020-04-01
And using llvm10

Thanks

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.