Failed [static] assertions in runtime for object construction

windows
(Saleem Abdulrasool) #1

I was experimenting with the new Visual Studio release by Microsoft. It seems have to have changes which are technically compatible as per the C++ specification bug trigger static assertion failures in the code base. In particular, the static assertions for the triviality of the constructor for the reference counting in the code base are getting triggered. In particular, this assertion does not hold true:

std::is_trivially_constructible<std::atomic<uint64_t>>

The constructor now guarantees initialization of the member which makes it non-trivial, triggering the static assertion in a few places. This shows up in the InlineRefCounts type (stdlib/public/SwiftShims/RefCount.h:119). There is no guarantee that the atomic value will be 0-initialized, so I'm not certain what the assertion is trying to ensure.

CC: @moiseev @Mike_Ash @gparker42

(Mike Ash) #2

I'd guess that it's because the constructor/destructor are never called, so it wants to ensure there's nothing important being skipped. Guaranteed initialization can be safely skipped but still messes with that. I can't think of a better way to handle this. Maybe this should be disable for Visual Studio, or removed altogether.

On another note, just FYI, @gparker42 is no longer at Apple and I don't know if he's still participating here in any capacity.