1 /*        $NetBSD: gcc_builtin_alloca.c,v 1.6 2025/04/12 15:49:49 rillig Exp $  */
2 # 3 "gcc_builtin_alloca.c"
3 
4 /*
5  * Test for the GCC builtin functions __builtin_alloca*, which unlike most
6  * other builtin functions return a pointer instead of int.
7  *
8  * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
9  */
10 
11 /* lint1-extra-flags: -X 351 */
12 
13 void
example(void)14 example(void)
15 {
16           char *ptr = __builtin_alloca(8);
17           ptr[4] = '4';
18 
19           char *aligned_ptr = __builtin_alloca_with_align(8, 64);
20           aligned_ptr[0] = '\0';
21 
22           /* expect+1: warning: invalid combination of pointer 'pointer to char' and integer 'int' for 'init' [183] */
23           char *unknown = __builtin_allocate(8);
24           unknown[0] = '\0';
25 }
26