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 摘要。