abseil / abseil/abseil-cpp

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

未關閉
#729 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
18.1k
分支
3.2k
平均合併
20 小時 36 分鐘
30 天內合併 PR
1

描述

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。