[PATCH] malloc: fix undefined behavior in obstack.h [BZ #32393]

Paul Eggert eggert@cs.ucla.edu
Tue Apr 29 17:43:54 GMT 2025


On 2025-04-28 20:39, Collin Funk wrote:

> +# define PTR_UINT_TYPE __UINTPTR_TYPE__

Let's call this new macro __PTR_UINT_TYPE instead, to avoid namespace 
pollution.


> +#define __PTR_ALIGN(B, P, A) \
> +  (sizeof (PTR_INT_TYPE) < sizeof (void *) \
> +   ? (B) + (((P) - (B) + (A)) & ~(A))      \
> +   : (P) + ((- (PTR_UINT_TYPE) (P)) & (A)))

This collides with Gnulib, which needs to do this a different way to 
avoid a compiler error with Oracle Developer Studio. Although admittedly 
it'll take a bit of work to merge with Gnulib, let's not make merging 
harder.

How about the attached patch instead?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-malloc-fix-undefined-behavior-in-obstack.h-BZ-32393.patch
Type: text/x-patch
Size: 3719 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250429/529e8874/attachment-0001.bin>


More information about the Libc-alpha mailing list