[libcxx-commits] [libcxx] [libc++] Inline `text_encoding` alias offset table std::count to 884 (PR #207471)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 4 00:53:28 PDT 2026


================
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <text_encoding>
+
+// REQUIRES: std-at-least-c++26
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=40000000
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=1000000000
+
+// Our table has 882 aliases exactly, test to make sure that number matches with the total alias count
+// Internally, there are 884 entries with 2 reserved for id::unknown and id::other
+#include <cassert>
+#include <ranges>
+#include <text_encoding>
+
+#include "test_text_encoding.h"
+
+constexpr bool test() {
+  long long sum = 0;
+  for (auto& enc : unique_encoding_data) {
+    std::text_encoding te{std::text_encoding::id(enc.mib)};
+
+    sum += std::ranges::size(te.aliases());
+  }
+
+  assert(sum == 882);
----------------
philnik777 wrote:

Can we test directly against `__num_aliases`? That's what we care is correct. That also means we don't have to modify the test if the header content gets updated correctly (unless that's somehow part of the ABI? I hope not?).

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


More information about the libcxx-commits mailing list