view gcc/testsuite/c-c++-common/Wstringop-truncation-3.c @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children
line wrap: on
line source

/* PR tree-optimization/84228 */
/* { dg-do compile } */
/* { dg-options "-Wstringop-truncation -O2 -g" } */

char *strncpy (char *, const char *, __SIZE_TYPE__);
struct S
{
  char arr[64];
};

int
foo (struct S *p1, const char *a)
{
  int b = 5, c = 6, d = 7;
  if (a)
    goto err;
  strncpy (p1->arr, a, sizeof p1->arr); /* { dg-bogus "specified bound" } */
  b = 8; c = 9; d = 10;
  p1->arr[3] = '\0';
err:
  return 0;
}