https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113099

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'm not sure what you mean by "the compiler is free to generate code that takes
it into account." Takes what into account? What problem does that freedom
cause?

The locale facet instantiations are compiled as C++11 (but other parts of the
library are compiled as C++17 or newer). We should do this so it uses
if-constexpr for everything except C++98:

--- a/libstdc++-v3/include/bits/locale_classes.tcc
+++ b/libstdc++-v3/include/bits/locale_classes.tcc
@@ -87,6 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                __s2.data(), __s2.data() + __s2.length()) < 0);
     }

+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wc++17-extensions"
   template<typename _Facet>
     inline const _Facet*
     __try_use_facet(const locale& __loc) _GLIBCXX_NOTHROW
@@ -97,7 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // We know these standard facets are always installed in every locale
       // so dynamic_cast always succeeds, just use static_cast instead.
 #define _GLIBCXX_STD_FACET(...) \
-      if _GLIBCXX17_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \
+      if _GLIBCXX_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \
        return static_cast<const _Facet*>(__facets[__i])

       _GLIBCXX_STD_FACET(ctype<char>);
@@ -145,6 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return static_cast<const _Facet*>(__facets[__i]);
 #endif
     }
+#pragma GCC diagnostic pop

   /**
    *  @brief  Test for the presence of a facet.

Reply via email to