aboutsummaryrefslogtreecommitdiff
path: root/2026-linuxdays/align.c
blob: 967069af391ea5912ed9cd466807234b0871b0e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <assert.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

typedef uint64_t uint64_unaligned_t [[gnu::aligned(1)]];

int main(void) {
  void *buf = malloc(BUFSIZ);
  char *ch = buf;
  uint64_unaligned_t *num = buf + 1;
  *num = 42;
  *ch = '!';
  free(buf);
  return 0;
}