Open Bug 1772175 Opened 3 years ago Updated 1 year ago

Update allocator API for C++17

Categories

(Core :: Memory Allocator, task)

task

Tracking

()

People

(Reporter: rkraesig, Unassigned)

References

Details

C++17 makes a number of changes to operator new to allow for support of over-aligned types.

In particular:

  • C++17 defines a new non-#defineable macro __STDCPP_DEFAULT_NEW_ALIGNMENT__, which is the minimum guaranteed alignment of the return value of new char().

  • New variants of the global ::operator new are defined which take a std::align_val_t to specify the alignment required by the type. These are automatically selected as the implementation of new T() when T has an alignment requirement greater than __STDCPP_DEFAULT_NEW_ALIGNMENT__.

We should make sure that we're consonant with the former (which may involve changing it via --faligned-new=), and that we provide/override the latter.

Addendum: the current state of affairs is that we disable all of the above, per bug 1560666:

# Likewise for C++17 and aligned allocation.  It's not immediately obvious
# from the clang and GCC documentation, but they both support this.
check_and_add_flag("-fno-aligned-new", compiler=cxx_compiler)

I suppose I'm requesting revisiting this decision. This isn't urgent, and I'm not aware of anything it blocks; it would just be nice to not have to care about this particular bit of trivia.

See Also: → 666088
You need to log in before you can comment on or make changes to this bug.