[libcxx-commits] [libcxx] [libc++] Don't export ABI tagged __str_to_float_c_locale specializations on MinGW (PR #229456)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 8 04:32:16 PDT 2026


================
@@ -175,32 +175,42 @@ _LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
 //
 
 // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
+#if defined(_LIBCPP_MSVCRT)
 template <class _FloatT>
 _LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
-#if defined(_LIBCPP_MSVCRT)
 
 template <>
 inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
   return ::_strtof_l(__nptr, __endptr, __get_c_locale());
 }
 
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+  return ::_strtod_l(__nptr, __endptr, __get_c_locale());
+}
+
 template <>
 inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
   return ::_strtold_l(__nptr, __endptr, __get_c_locale());
 }
 #else
-template <>
-_LIBCPP_EXPORTED_FROM_ABI float __str_to_float_c_locale<float>(const char*, char**);
+// No _LIBCPP_HIDE_FROM_ABI as exported specialisations must not inherit abi_tag.
+template <class _FloatT>
+_FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
 
 template <>
-_LIBCPP_EXPORTED_FROM_ABI long double __str_to_float_c_locale<long double>(const char*, char**);
-#endif
+_LIBCPP_EXPORTED_FROM_ABI float __str_to_float_c_locale<float>(const char*, char**);
 
+// _LIBCPP_HIDDEN not _LIBCPP_HIDE_FROM_ABI, can't add abi_tag when primary has none.
 template <>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+_LIBCPP_HIDDEN inline double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
----------------
philnik777 wrote:

Can we just use `_strtof_l` and `_strtold_l` instead and implement them all in the header?

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


More information about the libcxx-commits mailing list