78_vla_label.c 761 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <stdio.h>
  2. /* This test segfaults as of April 27, 2015. */
  3. void f1(int argc)
  4. {
  5. char test[argc];
  6. if(0)
  7. label:
  8. printf("boom!\n");
  9. if(argc-- == 0)
  10. return;
  11. goto label;
  12. }
  13. /* This segfaulted on 2015-11-19. */
  14. void f2(void)
  15. {
  16. goto start;
  17. {
  18. int a[1 && 1]; /* not a variable-length array */
  19. int b[1 || 1]; /* not a variable-length array */
  20. int c[1 ? 1 : 1]; /* not a variable-length array */
  21. start:
  22. a[0] = 0;
  23. b[0] = 0;
  24. c[0] = 0;
  25. }
  26. }
  27. void f3(void)
  28. {
  29. printf("%d\n", 0 ? printf("x1\n") : 11);
  30. printf("%d\n", 1 ? 12 : printf("x2\n"));
  31. printf("%d\n", 0 && printf("x3\n"));
  32. printf("%d\n", 1 || printf("x4\n"));
  33. }
  34. int main()
  35. {
  36. f1(2);
  37. f2();
  38. f3();
  39. return 0;
  40. }