File: offsetof-64.c

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,436 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (22 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu

// PR15216
// Don't crash when taking computing the offset of structs with large arrays.
const unsigned long Size = (1l << 60);

struct Chunk1 {
  char padding[Size];
  char more_padding[1][Size];
  char data;
};

int test1 = __builtin_offsetof(struct Chunk1, data);

struct Chunk2 {
  char padding[Size][Size][Size];  // expected-error 2{{array is too large}}
  char data;
};

// FIXME: Remove this error when the constant evaluator learns to
// ignore bad types.
int test2 = __builtin_offsetof(struct Chunk2, data);  // expected-error{{initializer element is not a compile-time constant}}