aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ubsan/align-1.C
blob: 65b1222a5c063120ce52b719e6761e363e475232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// { dg-do run }
// { dg-options "-fsanitize=alignment -Wall -Wno-unused-variable -std=c++11" }

typedef const long int L;
int a = 1;
L b = 2;

int
main (void)
{
  int *p = &a;
  L *l = &b;

  int &r = *p;
  auto &r2 = *p;
  L &lr = *l;

  // Try an rvalue reference.
  auto &&r3 = *p;

  // Don't evaluate the reference initializer twice.
  int i = 1;
  int *q = &i;
  int &qr = ++*q;
  if (i != 2)
    __builtin_abort ();
}