This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix __convert_to_v


Hi!

When building libstdc++ on powerpc*/sparc/s390{,x}/alpha-linux
--without-long-double-128 against glibc 2.4+, long double
__convert_to_v binds to wrong symbol version.  The problem
is that glibc 2.2+ only prototypes strtold_l in its headers,
not __strtold_l (which was only in glibc 2.1) and libstdc++-v3
prototypes __strtold_l itself:
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
...
extern "C" __typeof(strtold_l) __strtold_l;
...
#endif
But that means that glibc's redirect to strtod_l which is
present on strtold_l prototype when long double is 64-bit
isn't present on __strtold_l and thus we call __strtold_l
and pass it 64-bit long double, while __strtold_l@@GLIBC_2.4
expects 128-bit long double.

Fixed thusly, approved by Benjamin offline, committed
to 4.3/4.2/4.1.

2006-11-10  Jakub Jelinek  <jakub@redhat.com>

	* config/locale/gnu/c_locale.cc (__convert_to_v): Prefer
	strtold_l over __strtold_l if available.

--- libstdc++-v3/config/locale/gnu/c_locale.cc.jj	2006-02-13 22:21:28.000000000 +0100
+++ libstdc++-v3/config/locale/gnu/c_locale.cc	2006-11-09 19:21:26.000000000 +0100
@@ -77,7 +77,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     {
       char* __sanity;
       errno = 0;
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+      // Prefer strtold_l, as __strtold_l isn't prototyped in more recent
+      // glibc versions.
+      long double __ld = strtold_l(__s, &__sanity, __cloc);
+#else
       long double __ld = __strtold_l(__s, &__sanity, __cloc);
+#endif
       if (__sanity != __s && errno != ERANGE)
 	__v = __ld;
       else

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]