[PATCH] D126341: Order implicitly instantiated global variable's initializer by the reverse instantiation order

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 16:01:43 PDT 2022


ychen created this revision.
ychen added reviewers: rnk, rsmith, aaron.ballman.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

By the standard https://eel.is/c++draft/basic.start#dynamic-1, implicitly 
instantiated global variable's initializer has no order. However GCC has 
the *intuitive behavior* for the two test cases in https://clang.godbolt.org/z/MPdhYTqhK.

The underlying problem is basically wg21.link/cwg362 which has no concensus yet.

I wish both cases could work, like GCC. However, to make the original cwg362 test case work,
I needs an extra data structure to track the instantiation order for implicitly 
instantiated global variable. So the current patch only work for the first test case.

Will the reviewers be supportive if I make the original cwg362 test case work too?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126341

Files:
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
  clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
  clang/test/Modules/initializers.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126341.431823.patch
Type: text/x-patch
Size: 10113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220524/44c83cc8/attachment.bin>


More information about the cfe-commits mailing list