[PATCH v4] assert: Refactor assert/assert_perror
Yury Khrustalev
yury.khrustalev@arm.com
Fri Sep 26 10:44:17 GMT 2025
Hi Adhemerval,
On Thu, Aug 21, 2025 at 08:48:13AM -0300, Adhemerval Zanella wrote:
> It now calls __libc_assert, which contains similar logic. The assert
> call only requires memory allocation for the message translation, so
> test-assert2.c is adapted to handle it.
>
> It also removes the fxprintf from assert/assert_perror; although it
> is not 100% backwards-compatible (write message only if there is a
> file descriptor associated with the stderr). It now writes bytes
> directly without going through the wide stream state.
>
> Checked on aarch64-linux-gnu.
This change causes compilation error when compiling with -Og:
In file included from ../include/sys/cdefs.h:10,
from ../include/features.h:524,
from ../stdlib/errno.h:25,
from ../include/errno.h:2,
from ../sysdeps/unix/sysv/linux/libc_fatal.c:19:
../include/stdio.h: In function ‘__libc_message_wrapper’:
../misc/sys/cdefs.h:639:30: error: invalid use of ‘__builtin_va_arg_pack_len ()’
639 | # define __va_arg_pack_len() __builtin_va_arg_pack_len ()
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/stdio.h:191:7: note: in expansion of macro ‘__va_arg_pack_len’
191 | if (__va_arg_pack_len () > LIBC_MESSAGE_MAX_ARGS)
| ^~~~~~~~~~~~~~~~~
In file included from ../sysdeps/posix/libc_fatal.c:23,
from ../sysdeps/unix/sysv/linux/libc_fatal.c:36:
../include/stdio.h:194:7: error: call to ‘__libc_message_error’ declared with attribute error: invalid number of arguments
194 | __libc_message_error ();
| ^~~~~~~~~~~~~~~~~~~~~~~
../include/stdio.h:197:3: error: invalid use of ‘__builtin_va_arg_pack ()’
197 | __libc_message_impl (vmaname, fmt, __va_arg_pack ());
> ...
>
> diff --git a/include/stdio.h b/include/stdio.h
> index 3d917dba5b..d9a839e115 100644
> --- a/include/stdio.h
> +++ b/include/stdio.h
>
> ...
>
> +static inline _Noreturn void __libc_message_wrapper (const char *vmaname,
> + const char *fmt, ...)
I think this should also have __attribute__ ((__always_inline__)) to
make use of __builtin_va_arg_pack_len() valid for all optimisation
levels.
Thanks,
Yury
More information about the Libc-alpha
mailing list