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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-08-06
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Rainer Orth from comment #0)
> Thew new 18_support/new_aligned.cc test FAILs on Solaris 10 (sparc and x86),
> which lacks aligned_alloc in libc:

Ah good, I thought that testcase might shake out some more Solaris bugs :-)

Which implementation in libsupc++/new_opa.cc gets used? Is posix_memalign
available? Or memalign?

I'm guessing it uses memalign, and Solaris memalign has an additional
requirement that posix_memalign has, but GNU memalign doesn't:

  The value of alignment must be a power of two and must be greater than or
  equal to the size of a word.

So maybe this will fix it:

--- a/libstdc++-v3/libsupc++/new_opa.cc
+++ b/libstdc++-v3/libsupc++/new_opa.cc
@@ -53,7 +53,14 @@ aligned_alloc (std::size_t al, std::size_t sz)
 #else
 extern "C" void *memalign(std::size_t boundary, std::size_t size);
 #endif
-#define aligned_alloc memalign
+static inline void*
+aligned_alloc (std::size_t al, std::size_t sz)
+{
+  // Solaris requires that sz is greater than or equal to sizeof(int)
+  if (al < sizeof(int))
+    al = sizeof(int);
+  return memalign (al, sz);
+}
 #else
 #include <stdint.h>
 // The C library doesn't provide any aligned allocation functions, define one.

Reply via email to