[Bug middle-end/83373] False positive reported by -Wstringop-overflow

bugzilla@poradnik-webmastera.com gcc-bugzilla@gcc.gnu.org
Wed Dec 13 20:52:00 GMT 2017


--- Comment #6 from Daniel Fruzynski <bugzilla@poradnik-webmastera.com> ---
My understanding is that after this patch will be applied, gcc will still emit
warning for last field in struct, e.g. like in code below. Is my understanding
correct or I missed something?

struct Msg
  int op;
  char str1[100];
  char str2[100];


void func()
  Msg msg;
  msg.op = 5;

  char data1[20], data2[20];

  my_strcpy(msg.str1, data1, sizeof(msg.str1)); // OK, no warning
  my_strcpy(msg.str2, data2, sizeof(msg.str2)); // Warning still present

  send_msg(&msg, sizeof(msg));

More information about the Gcc-bugs mailing list