Skip to content
Snippets Groups Projects
  • Alan Modra's avatar
    b0321032
    obstack.h __PTR_ALIGN vs. ubsan · b0321032
    Alan Modra authored
    Current ubsan complains on every use of __PTR_ALIGN (when ptrdiff_t is
    as large as a pointer), due to making calculations relative to a NULL
    pointer.  This patch avoids the problem by extracting out and
    simplifying __BPTR_ALIGN for the usual case.  I've continued to use
    ptrdiff_t here, where it might be better to throw away __BPTR_ALIGN
    entirely and just assume uintptr_t exists.
    
    	* obstack.h (__PTR_ALIGN): Expand and simplify __BPTR_ALIGN
    	rather than calculating relative to a NULL pointer.
    b0321032
    History
    obstack.h __PTR_ALIGN vs. ubsan
    Alan Modra authored
    Current ubsan complains on every use of __PTR_ALIGN (when ptrdiff_t is
    as large as a pointer), due to making calculations relative to a NULL
    pointer.  This patch avoids the problem by extracting out and
    simplifying __BPTR_ALIGN for the usual case.  I've continued to use
    ptrdiff_t here, where it might be better to throw away __BPTR_ALIGN
    entirely and just assume uintptr_t exists.
    
    	* obstack.h (__PTR_ALIGN): Expand and simplify __BPTR_ALIGN
    	rather than calculating relative to a NULL pointer.