[clang] [clang][CodeGen] Use dynamic init for vague-linkage variables without constant initialization (PR #226645)

Divyansh Yadav via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 16 02:19:27 PDT 2026


schizophrenicmaniac wrote:

> Looking at https://github.com/itanium-cxx-abi/cxx-abi/issues/121, I'm a little more concerned about potential breakage.  Not sure what to do about that.

I checked GCC 15. It agrees with this patch for the original issue and for `inline const int IV = K + 1;` with K defined later (both dynamic), but it initializes the #121 example statically, and so did clang before this patch, so the patch introduces a mismatch there. It looks like GCC only folds what it can fold at the point of the definition, which is the same in every TU. Would it be acceptable to only force dynamic init when folding depends on something that isn't known at the point of definition, like a variable whose initializer comes later? That would keep the #121 case and the is_constant_evaluated case static.


https://github.com/llvm/llvm-project/pull/226645


More information about the cfe-commits mailing list