RFA (libstdc++): PATCH to implement C++17 over-aligned new

Jonathan Wakely jwakely@redhat.com
Sun Sep 11 09:55:00 GMT 2016


On 11/09/16 10:38 +0100, Jonathan Wakely wrote:
>On 11/09/16 09:08 +0200, Christophe Lyon wrote:
>>On 10 September 2016 at 08:59, Christophe Lyon
>><christophe.lyon@linaro.org> wrote:
>>>On 9 September 2016 at 23:20, Jason Merrill <jason@redhat.com> wrote:
>>>>On Thu, Sep 8, 2016 at 7:06 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
>>>>>On 08/09/16 09:10 +0200, Marc Glisse wrote:
>>>>>>
>>>>>>Do we want a generic fallback implementation (similar to
>>>>>>gcc/config/i386/gmm_malloc.h)? A windows version with _aligned_malloc /
>>>>>>_aligned_free would also be possible.
>>>>>
>>>>>Making it work for MinGW would be nice.
>>>>
>>>>OK, this is what I'm checking in; could someone test it on MinGW?
>>>>
>>>>Jason
>>>
>>>Hi Jason,
>>>
>>>I'm seeing problems on arm*linux: the tests aligned-new[1235].C fail to link:
>>>aligned-new5.C:(.text+0x14): undefined reference to `operator
>>>new(unsigned int, std::align_val_t)'
>>>
>>>
>>>On aarch64*-elf and arm-eabi (using newlib), I'm seeing:
>>>/gccsrc/libstdc++-v3/libsupc++/new_opa.cc:66: undefined reference to
>>>`aligned_alloc'
>>>
>>>Am I missing something in my setup?
>>>
>>
>>I'm seeing an additional problem: to GCC build is broken after this
>>commit for target arm-none-eabi (using default cpu):
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:
>>In function 'void* operator new(std::size_t, std::align_val_t, const
>>std::nothrow_t&)':
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:33:3:
>>error: '__try' was not declared in this scope
>>  __try
>>  ^~~~~
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:37:11:
>>error: expected primary-expression before '...' token
>>  __catch(...)
>>          ^~~
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:37:3:
>>error: '__catch' was not declared in this scope
>>  __catch(...)
>>  ^~~~~~~
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:41:1:
>>warning: no return statement in function returning non-void
>>[-Wreturn-type]
>>}
>>^
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:30:26:
>>warning: unused parameter 'sz' [-Wunused-parameter]
>>operator new(std::size_t sz, std::align_val_t al, const std::nothrow_t&)
>>                         ^~
>>/home/christophe.lyon/src/GCC/sources/gcc-fsf/reg-240062/libstdc++-v3/libsupc++/new_opant.cc:30:47:
>>warning: unused parameter 'al' [-Wunused-parameter]
>>operator new(std::size_t sz, std::align_val_t al, const std::nothrow_t&)
>>                                              ^~
>>make[4]: *** [new_opant.lo] Error 1
>>make[4]: Leaving directory
>>`/home/christophe.lyon/src/GCC/builds/gcc-fsf-reg-240062/obj-arm-none-eabi/gcc3/arm-none-eabi/libstdc++-v3/libsupc++'
>
>Hmm, I'm not sure why it's not failing on all targets, [...]

OK, I see why. <bits/exception_defines.h> gets included indirectly at
the end of <exception> via

#if (__cplusplus >= 201103L) && (ATOMIC_INT_LOCK_FREE > 1)
#include <bits/exception_ptr.h>
#include <bits/nested_exception.h>
#endif

The condition isn't true for all targets.

So including it explicitly in new_opant.cc is the right fix.



More information about the Libstdc++ mailing list