[libcxx-commits] [PATCH] D110647: [SystemZ][z/OS] Resolve missing table_size symbol

Muiez Ahmed via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 28 11:58:23 PDT 2021


muiez created this revision.
muiez added reviewers: libc++, Quuxplusone.
muiez requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

The aim of this patch is to resolve the missing `table_size` symbol (see reduced test case). That const variable is declared and defined in //libcxx/include/locale//; however, the test case suggests that the symbol is missing. This is due to a C++ pitfall (highlighted here <https://quuxplusone.github.io/blog/2020/09/19/value-or-pitfall/>). In summary, assigning the reference of `table_size` doesn't enforce the const-ness and expects to find `table_size` in the DLL. The fix is to use `constexpr`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110647

Files:
  libcxx/include/__locale


Index: libcxx/include/__locale
===================================================================
--- libcxx/include/__locale
+++ libcxx/include/__locale
@@ -712,9 +712,9 @@
     static locale::id id;
 
 #ifdef _CACHED_RUNES
-    static const size_t table_size = _CACHED_RUNES;
+    static _LIBCPP_CONSTEXPR const size_t table_size = _CACHED_RUNES;
 #else
-    static const size_t table_size = 256;  // FIXME: Don't hardcode this.
+    static _LIBCPP_CONSTEXPR const size_t table_size = 256;  // FIXME: Don't hardcode this.
 #endif
     _LIBCPP_INLINE_VISIBILITY const mask* table() const  _NOEXCEPT {return __tab_;}
     static const mask* classic_table()  _NOEXCEPT;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110647.375659.patch
Type: text/x-patch
Size: 670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210928/a1144184/attachment.bin>


More information about the libcxx-commits mailing list