Re: [patch] aligned_alloc: conform to C17

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/16/23 13:48, DJ Delorie via Libc-alpha wrote:
+  /* Similar to memalign, but ISO C17 requires an error for invalid
+     alignments.  Valid alignments are non-negative powers of two.  */
+  if (!powerof2 (alignment))

powerof2 (0) == 1, unfortunately. Does the C standard let aligned_alloc (alignment, size) succeed when ALIGNMENT is zero? I think not, as zero is 2**-Infinity, and -Infinity is not non-negative. So that line should be changed to something like 'if (!powerof2 (alignment) || alignment == 0)'.

There may be other occurrences of this issue in Glibc already; I haven't checked.



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux