This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/55727] better support for dynamic allocation of over-aligned types


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55727

--- Comment #4 from Matthias Kretz <kretz at kde dot org> 2012-12-18 18:20:00 UTC ---
Created attachment 29002
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29002
support for over-aligned types in new_allocator

I finished my allocator to fix the issue and it was easy to port it over to
new_allocator. So here's the patch.

Questions:
1. I use sizeof(void*) for the natural alignment or alignof(std::max_align_t)
for C++11. Is there a better way to do this?
2. I'm not sure you like the way I abuse enum for compile-time constants. May I
use constexpr, or would that have to be ifdefed?
3. What's the proper integer type to use for pointer manipulation? I'd really
like to write __p &= ~__alignment_mask, but I don't see how to not breaking
strict-aliasing with this.

Note that new_allocator will compile to the same code as long as alignof(_Tp1)
is <= alignof(std::max_align_t). The extra code to handle alignment will only
kick in for over-aligned types - and those want the extra complexity.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]