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

--- Comment #11 from David Krauss <potswa at mac dot com> ---
No, that code wasn't right either. I'll just leave it at this and a caveat to
the reader:

inline void *align( std::size_t alignment, std::size_t size,
                    void *&ptr, std::size_t &space ) {
    std::uintptr_t pn = reinterpret_cast< std::uintptr_t >( ptr );
    std::uintptr_t aligned = ( pn + alignment - 1 ) & - alignment;
    std::size_t padding = aligned - pn;
    if ( space < size + padding ) return nullptr;
    space -= padding;
    return ptr = reinterpret_cast< void * >( aligned );
}

Reply via email to