abseil / abseil/abseil-cpp

Does not compile on windows (MSVC)

未关闭
#1,337 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
C++
星标
18.1k
派生
3.2k
平均合并
20 小时 36 分钟
30 天内合并 PR
1

描述

As known, (see https://github.com/abseil/abseil-cpp/blob/master/absl/base/internal/atomic_hook.h#L139, https://github.com/abseil/abseil-cpp/issues/659, etc.), MSVC does not provide a constinit std::atomic.

But, both https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_handle.cc#L27 and https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_info.cc#L41 attempt to define a ABSL_CONST_INIT object which contain a std::atomic (https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_handle.h#L90, https://github.com/abseil/abseil-cpp/blob/master/absl/strings/internal/cordz_info.h#L196).

This makes absl not compilable with the latest MSVC.

I see a macro ABSL_INTERNAL_CORDZ_ENABLED https://github.com/abseil/abseil-cpp/blob/72ec15a317a74cccf03a62f749f3ab28206be069/absl/strings/internal/cordz_functions.h#L47, which is false for MSVC; does this mean cordz_info and cordz_handle are not even needed, as a simple 'fix'? Or do we need a different workaround?

```
absl\strings\internal\cordz_info.cc:41:44: error: variable does not have a constant initializer
ABSL_CONST_INIT CordzInfo::List CordzInfo::global_list_{absl::kConstInit};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
absl\strings\internal\cordz_info.cc:41:1: note: required by 'require_constant_initialization' attribute here
ABSL_CONST_INIT CordzInfo::List CordzInfo::global_list_{absl::kConstInit};
^~~~~~~~~~~~~~~
absl/base/attributes.h:714:27: note: expanded from macro 'ABSL_CONST_INIT'
#define ABSL_CONST_INIT [[clang::require_constant_initialization]]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...xxatomic:207:21: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
: _Atomic_address{(_ATOMIC_UINT)_Right}
^
abseil-cpp\absl/strings/internal/cordz_info.h:196:56: note: in call to 'atomic(nullptr)'
std::atomic head ABSL_GUARDED_BY(mutex){nullptr};
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。