[swift-dev] New global constructor warnings in runtime GlobalObjects.cpp

Joe Groff jgroff at apple.com
Tue May 2 11:02:56 CDT 2017


After updating clang recently, I'm seeing these warnings:

/Users/jgroff/src/s/swift/stdlib/public/stubs/GlobalObjects.cpp:40:39: warning: declaration requires a global constructor [-Wglobal-constructors]
swift::_SwiftEmptyArrayStorage swift::_swiftEmptyArrayStorage = {
                                      ^                         ~
/Users/jgroff/src/s/swift/stdlib/public/stubs/GlobalObjects.cpp:55:44: warning: declaration requires a global constructor [-Wglobal-constructors]
swift::_SwiftEmptyDictionaryStorage swift::_swiftEmptyDictionaryStorage = {
                                           ^                              ~
/Users/jgroff/src/s/swift/stdlib/public/stubs/GlobalObjects.cpp:83:37: warning: declaration requires a global constructor [-Wglobal-constructors]
swift::_SwiftEmptySetStorage swift::_swiftEmptySetStorage = {
                                    ^                       ~

Looking at the definitions of those objects, it isn't clear to me why they would require global constructors. The types are POD, and their initializers only contain pointers to other globals, which ought to be resolvable by the linker. I also didn't see any recent change to the runtime that seems like it would trigger a change here. Is this a clang bug?

-Joe


More information about the swift-dev mailing list