https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90569
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-05-22
Ever confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I thought we could workaround this in libstdc++ like so:
diff --git a/libstdc++-v3/libsupc++/Makefile.am
b/libstdc++-v3/libsupc++/Makefile.am
index eec7b953514..a50a9848461 100644
--- a/libstdc++-v3/libsupc++/Makefile.am
+++ b/libstdc++-v3/libsupc++/Makefile.am
@@ -129,6 +129,8 @@ cp-demangle.o: cp-demangle.c
# Use special rules for the C++17 sources so that the proper flags are passed.
+new_op.lo: new_op.cc
+ $(LTCXXCOMPILE) -std=gnu++1z -c $<
new_opa.lo: new_opa.cc
$(LTCXXCOMPILE) -std=gnu++1z -c $<
new_opant.lo: new_opant.cc
diff --git a/libstdc++-v3/libsupc++/Makefile.in
b/libstdc++-v3/libsupc++/Makefile.in
index 5d8ac5ca0ba..0e3cbff0055 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -956,6 +956,8 @@ cp-demangle.o: cp-demangle.c
$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
# Use special rules for the C++17 sources so that the proper flags are passed.
+new_op.lo: new_op.cc
+ $(LTCXXCOMPILE) -std=gnu++1z -c $<
new_opa.lo: new_opa.cc
$(LTCXXCOMPILE) -std=gnu++1z -c $<
new_opant.lo: new_opant.cc
diff --git a/libstdc++-v3/libsupc++/new_op.cc
b/libstdc++-v3/libsupc++/new_op.cc
index 863530b7564..203c57d9171 100644
--- a/libstdc++-v3/libsupc++/new_op.cc
+++ b/libstdc++-v3/libsupc++/new_op.cc
@@ -27,6 +27,9 @@
#include <cstdlib>
#include <bits/exception_defines.h>
#include "new"
+#if defined __sun__ || defined __i386__
+# include <cstddef>
+#endif
using std::new_handler;
using std::bad_alloc;
@@ -41,6 +44,14 @@ extern "C" void *malloc (std::size_t);
_GLIBCXX_WEAK_DEFINITION void *
operator new (std::size_t sz) _GLIBCXX_THROW (std::bad_alloc)
{
+#if defined __sun__ || defined __i386__
+ if (sz >= alignof(std::max_align_t))
+ {
+ std::align_val_t al{alignof(std::max_align_t)};
+ return ::operator new(sz, al);
+ }
+#endif
+
void *p;
/* malloc (0) is unpredictable; avoid it. */
This would force operator new to use aligned_alloc instead of malloc for
allocations that might be for objects large enough to require greater alignment
than malloc guarantees. But since Solaris 11 doesn't appear to define
aligned_alloc, this would use the fallback implementation in
libsupc++/new_opa.cc which is much less efficient than plain malloc.