File: variadic5.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (22 lines) | stat: -rw-r--r-- 399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stddef.h>
#include <stdarg.h>
#include "test.h"

typedef struct {
  char _Alignas(1024) pad;
} BigAlign;

void test(int count, ...) {
  va_list ap;
  va_start(ap, count);

  for (int i = 0; i < count; i++)
    printf("arg[%d] = %p\n", i, va_arg(ap, void *));

  va_end(ap);
}

int main() {
  BigAlign a, b;
  test(2, &a, &b);  // If va_area isn't big enough or not aligned, crash likely
}