[Bug libstdc++/71856] [6/7 Regression] _GLIBCXX_DEBUG-mode breaks GNU parallel extension

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Oct 5 16:13:00 GMT 2016


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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This should ensure __glibcxx_assert() is empty unless _GLIBCXX_ASSERTIONS is
defined, but _GLIBCXX_PARALLEL_ASSERT() still expands to an assertion.

--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -442,9 +442,7 @@ namespace std
 #endif

 // Assert.
-#if !defined(_GLIBCXX_ASSERTIONS) && !defined(_GLIBCXX_PARALLEL)
-# define __glibcxx_assert(_Condition)
-#else
+#if defined(_GLIBCXX_ASSERTIONS) || defined(_GLIBCXX_PARALLEL)
 namespace std
 {
   // Avoid the use of assert, because we're trying to keep the <cassert>
@@ -458,7 +456,7 @@ namespace std
     __builtin_abort();
   }
 }
-#define __glibcxx_assert(_Condition)                                    \
+#define __glibcxx_assert_(_Condition)                                   \
   do                                                                    \
   {                                                                     \
     if (! (_Condition))                                                  \
@@ -467,6 +465,12 @@ namespace std
   } while (false)
 #endif

+#if defined(_GLIBCXX_ASSERTIONS)
+# define __glibcxx_assert(_Condition) __glibcxx_assert_(_Condition)
+#else
+# define __glibcxx_assert(_Condition)
+#endif
+
 // Macros for race detectors.
 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
--- a/libstdc++-v3/include/parallel/base.h
+++ b/libstdc++-v3/include/parallel/base.h
@@ -419,7 +419,7 @@ namespace __gnu_parallel
        }
     }

-#define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert(_Condition)
+#define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert_(_Condition)

 } //namespace __gnu_parallel



However this means that certain assertions in parallel mode are enabled
unconditionally e.g. in <parallel/find.h>

        default:
          _GLIBCXX_PARALLEL_ASSERT(false);
          return std::make_pair(__begin1, __begin2);

It looks like that's always been the case, but surely can't be what was
intended.

So maybe <parallel/base.h> should do:

#if _GLIBCXX_PARALLEL_ASSERTIONS
#define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert_(_Condition)
#else
#define _GLIBCXX_PARALLEL_ASSERT(_Condition)
#endif


More information about the Gcc-bugs mailing list