[libcxx-commits] [libcxx] [libc++] Fix the visibility of type traits (PR #111522)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 9 06:54:47 PDT 2024


================
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Make sure that the types and variables have the correct visibility attributes
+
+// RUN: %{cxx} %s %{flags} %{compile_flags} %{link_flags} -DSHARED -fPIC -fvisibility=hidden -shared -o %t.shared_lib
+// RUN: %{build} -fvisibility=hidden %t.shared_lib
+// RUN: %{run}
+
+#include <algorithm>
+#include <cassert>
+#include <type_traits>
+#include <vector>
+
+[[gnu::visibility("default")]] extern std::vector<const std::type_info*> shared_lib_type_infos;
+
+struct [[gnu::visibility("default")]] S {
+  static constexpr bool value = false;
+};
+
+inline std::vector<const std::type_info*> get_type_infos() {
+  return {
+      &typeid(std::remove_const<int>),
----------------
ldionne wrote:

I really question the value of this. For the inline variables, sure, but do we really want to get into the business of providing this guarantee for arbitrary type traits? The value this provides to users seems to be really small.

By the way, do we have the same problem for nearly all other types in the library?

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


More information about the libcxx-commits mailing list