1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // PR15216 4*f4a2713aSLionel Sambuc // Don't crash when taking computing the offset of structs with large arrays. 5*f4a2713aSLionel Sambuc const unsigned long Size = (1l << 60); 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc struct Chunk1 { 8*f4a2713aSLionel Sambuc char padding[Size]; 9*f4a2713aSLionel Sambuc char more_padding[1][Size]; 10*f4a2713aSLionel Sambuc char data; 11*f4a2713aSLionel Sambuc }; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc int test1 = __builtin_offsetof(struct Chunk1, data); 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc struct Chunk2 { 16*f4a2713aSLionel Sambuc char padding[Size][Size][Size]; // expected-error 2{{array is too large}} 17*f4a2713aSLionel Sambuc char data; 18*f4a2713aSLionel Sambuc }; 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc // FIXME: Remove this error when the constant evaluator learns to 21*f4a2713aSLionel Sambuc // ignore bad types. 22*f4a2713aSLionel Sambuc int test2 = __builtin_offsetof(struct Chunk2, data); // expected-error{{initializer element is not a compile-time constant}} 23