On 12/11/15 13:39 +0000, Jonathan Wakely wrote:
One downside of this change is that we introduce some (hopefully safe)
ODR violations, where inline functions and templates that depend on
_GLIBCXX_USE_C99_FOO might now be defined differently in C++98 and
C++11 code. Previously they had the same definition, even though in
C++11 mode the value of the _GLIBCXX_USE_C99_FOO macro might have been
sub-optimal (i.e. the C99 features were usable, but the macro said
they weren't). Those ODR violatiosn could be avoided if needed, by
always using the _GLIBCXX98_USE_C99_FOO macro in code that can be
included from either C++98 or C++11. We could still use the
_GLIBCXX11_USE_C99_FOO macro in pure C++11 code (such as the numeric
conversion functions) and get most of the benefit of this change.

This patch (relative to the previous one) would avoid the ODR
problems, by only using the C++98 macro in code that gets used in
C++98 and later, and using the _GLIBCXX11_XXX ones in code that is
never compiled as C++98 (specifically, the numeric conversion
functions).

Maybe this is a safer, more conservative change.

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index deefa04..11dee8e 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -960,7 +960,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
     ])
     AC_MSG_RESULT($glibcxx_cv_c99_math_cxx98)
     if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
-      AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
+      AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
         [Define if C99 functions or macros in <math.h> should be imported
         in <cmath> in namespace std for C++98.])
     fi
@@ -1029,7 +1029,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
     fi
     AC_MSG_RESULT($glibcxx_cv_c99_complex_cxx98)
     if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
-      AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,
+      AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
         [Define if C99 functions in <complex.h> should be used in
         <complex> for C++98. Using compiler builtins for these functions
         requires corresponding C99 library functions to be present.])
@@ -1054,7 +1054,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
     ])
     AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx98)
     if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then
-      AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1,
+      AC_DEFINE(_GLIBCXX_USE_C99_STDIO, 1,
         [Define if C99 functions or macros in <stdio.h> should be imported
         in <cstdio> in namespace std for C++98.])
     fi
@@ -1100,7 +1100,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
 
       AC_MSG_RESULT($glibcxx_cv_c99_wchar_cxx98)
       if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then
-        AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1,
+        AC_DEFINE(_GLIBCXX_USE_C99_WCHAR, 1,
           [Define if C99 functions or macros in <wchar.h> should be imported
           in <cwchar> in namespace std for C++98.])
       fi
diff --git a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
index 055c5b6..b21726f 100644
--- a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
@@ -37,5 +37,8 @@
 #define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
 #define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
 #define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED)
+#define _GLIBCXX11_USE_C99_STDIO 1
+#define _GLIBCXX11_USE_C99_STDLIB 1
+#define _GLIBCXX11_USE_C99_WCHAR 1
 
 #endif
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index b3853cd..2fa345a 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -5396,7 +5396,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
-#if _GLIBCXX_USE_C99_STDLIB
+#if _GLIBCXX11_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
@@ -5435,9 +5435,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   inline long double
   stold(const string& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
-#endif // _GLIBCXX_USE_C99_STDLIB
+#endif // _GLIBCXX11_USE_C99_STDLIB
 
-#if _GLIBCXX_USE_C99_STDIO
+#if _GLIBCXX11_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -5501,9 +5501,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
 					   "%Lf", __val);
   }
-#endif // _GLIBCXX_USE_C99_STDIO
+#endif // _GLIBCXX11_USE_C99_STDIO
 
-#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX11_USE_C99_WCHAR)
   inline int 
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -5605,7 +5605,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 					    L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX11_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 6bcf842..924f13e 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -529,40 +529,4 @@ namespace std
 #undef min
 #undef max
 
-// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
-// so they should be tested with #if not with #ifdef.
-#if __cplusplus >= 201103L
-# ifndef _GLIBCXX_USE_C99_MATH
-#  define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
-# endif
-# ifndef _GLIBCXX_USE_C99_COMPLEX
-# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDIO
-# define _GLIBCXX_USE_C99_CSTDIO _GLIBCXX11_USE_C99_CSTDIO
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDLIB
-# define _GLIBCXX_USE_C99_CSTDLIB _GLIBCXX11_USE_C99_CSTDLIB
-# endif
-# ifndef _GLIBCXX_USE_C99_WCHAR
-# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
-# endif
-#else
-# ifndef _GLIBCXX_USE_C99_MATH
-#  define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
-# endif
-# ifndef _GLIBCXX_USE_C99_COMPLEX
-# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDIO
-# define _GLIBCXX_USE_C99_CSTDIO _GLIBCXX98_USE_C99_CSTDIO
-# endif
-# ifndef _GLIBCXX_USE_C99_CSTDLIB
-# define _GLIBCXX_USE_C99_CSTDLIB _GLIBCXX98_USE_C99_CSTDLIB
-# endif
-# ifndef _GLIBCXX_USE_C99_WCHAR
-# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
-# endif
-#endif
-
 // End of prewritten config; the settings discovered at configure time follow.
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 8732bd3..36122d4 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -2688,7 +2688,7 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-#if _GLIBCXX_USE_C99_STDLIB
+#if _GLIBCXX11_USE_C99_STDLIB
   // 21.4 Numeric Conversions [string.conversions].
   inline int
   stoi(const __vstring& __str, std::size_t* __idx = 0, int __base = 10)
@@ -2727,9 +2727,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline long double
   stold(const __vstring& __str, std::size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
-#endif // _GLIBCXX_USE_C99_STDLIB
+#endif // _GLIBCXX11_USE_C99_STDLIB
 
-#if _GLIBCXX_USE_C99_STDIO
+#if _GLIBCXX11_USE_C99_STDIO
   // NB: (v)snprintf vs sprintf.
 
   // DR 1261.
@@ -2792,9 +2792,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __gnu_cxx::__to_xstring<__vstring>(&std::vsnprintf, __n,
 					      "%Lf", __val);
   }
-#endif // _GLIBCXX_USE_C99_STDIO
+#endif // _GLIBCXX11_USE_C99_STDIO
 
-#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX_USE_C99_WCHAR)
+#if defined(_GLIBCXX_USE_WCHAR_T) && defined(_GLIBCXX11_USE_C99_WCHAR)
   inline int 
   stoi(const __wvstring& __str, std::size_t* __idx = 0, int __base = 10)
   { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
@@ -2895,7 +2895,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 					       L"%Lf", __val);
   }
 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
-#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
+#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX11_USE_C99_WCHAR
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace

Reply via email to