mirror of
https://sourceware.org/git/glibc.git
synced 2025-11-15 15:21:18 +03:00
C23 makes assert into a variadic macro to handle cases of an argument that would be interpreted as a single function argument but more than one macro argument (in particular, compound literals with an unparenthesized comma in an initializer list); this change was made by N2829. Note that this only applies to assert, not to other macros specified in the C standard with particular numbers of arguments. Implement this support in glibc. This change is only for C; C++ would need a separate change to its separate assert implementations. It's also applied only in C23 mode. It depends on support for (C99) variadic macros, and also (in order to detect calls where more than one expression is passed, via an unevaluated function call) a C99 boolean type. These requirements are encapsulated in the definition of __ASSERT_VARIADIC. Tests with -std=c99 and -std=gnu99 (using implementations continue to work. I don't think we have a way in the glibc testsuite to validate that passing more than one expression as an argument does produce the desired error. Tested for x86_64.
45 B
45 B