The message is currently something like memalign() invalid size value: 0 For consistency I think that should be something like Invalid size value: 0 (memalign() size of 0 is implementation defined) At present 4 functions are affected posix_memalign - implementation defined by POSIX memalign - non-standard that can and does do just about anything aligned_alloc - implementation defined by ISO C which passes the buck and says it is implementation defined free_sized_aligned - can't remember why I did this (but I didn't do free_sized) I need to revisit my research into what all these functions do on new glibc, old glibc, FreeBSD, Solaris, macOS, musl, ptmalloc and maybe a couple more.
I've done a load of tests for size of zero add alignment of zero https://github.com/paulfloyd/aligned_errors and pushed a few fixes to the code. I don't think that I checked whether posix_memalign allocates or not with a size of zero.
Created attachment 184792 [details] Initial patch only tested on FreeBSD Need tol check on Linux and illumos
Created attachment 184793 [details] Updated for Linux next stop illumos
commit 66f0174466cd0d97d1b123ac8152797fb34aeb8c (HEAD -> master, origin/master, origin/HEAD) Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Sun Sep 7 22:01:34 2025 +0200 Bug 509139 - Update BadSize error messages