libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr115387-1.c
blob7ff3ced07bf898cd53b55617d659774e8af32aa1
1 /* Test there is no ICE when compile. */
2 /* { dg-do compile } */
4 #define PRINTF_CHK 0x34
6 typedef __UINTPTR_TYPE__ uintptr_t;
8 struct __printf_buffer {
9 char *write_ptr;
10 int status;
13 extern void __printf_buffer_init_end (struct __printf_buffer *, char *, char *);
15 void
16 test (char *string, unsigned long maxlen, unsigned mode_flags)
18 struct __printf_buffer buf;
20 if ((mode_flags & PRINTF_CHK) != 0)
22 string[0] = '\0';
23 uintptr_t end;
25 if (__builtin_add_overflow ((uintptr_t) string, maxlen, &end))
26 end = -1;
28 __printf_buffer_init_end (&buf, string, (char *) end);
30 else
31 __printf_buffer_init_end (&buf, string, (char *) ~(uintptr_t) 0);
33 *buf.write_ptr = '\0';