public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "drc at linux dot vnet.ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/102316] New: Unexpected stringop-overflow Warnings on POWER CPU
Date: Mon, 13 Sep 2021 20:15:57 +0000	[thread overview]
Message-ID: <bug-102316-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102316

            Bug ID: 102316
           Summary: Unexpected stringop-overflow Warnings on POWER CPU
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drc at linux dot vnet.ibm.com
  Target Milestone: ---

Building DPDK with gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3) on a POWER9
host and powerpc64le-linux-gnu-gcc (GCC) 11.2.1 20210802 (Advance-Toolchain
15.0-0) [ebcfb7a665c2] on an x86_64 cross-compile host, generates the warning:

In function ‘i40e_flow_parse_fdir_pattern’,
    inlined from ‘i40e_flow_parse_fdir_filter’ at
../drivers/net/i40e/i40e_flow.c:3274:8:
../drivers/net/i40e/i40e_flow.c:3052:69: warning: writing 1 byte into a region
of size 0 [-Wstringop-overflow=]
 3052 |                                 filter->input.flow_ext.flexbytes[j] =
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 3053 |                                         raw_spec->pattern[i];
      |                                         ~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/net/i40e/i40e_flow.c:25:
../drivers/net/i40e/i40e_flow.c: In function ‘i40e_flow_parse_fdir_filter’:
../drivers/net/i40e/i40e_ethdev.h:630:17: note: at offset 16 into destination
object ‘flexbytes’ of size 16
  630 |         uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
      |                 ^~~~~~~~~

See https://bugs.dpdk.org/show_bug.cgi?id=743 for additional details on DPDK
build failure.  

Running cvise to reduce the failing code yields the following simplified test
failure:

#include <stdlib.h>

#define LEN 16
struct {
  char c[LEN]
} d;

int a = LEN;
char* b;

int p() {
  for (int i = 0; i < a; i++) {
    d.c[i] = b[i];
  }
  return 0;
}

int main () {
  int r = 0;
  b = malloc(sizeof(char) * (LEN + 1));
  r = p();
  return r;
}


$ gcc -O3 test.c
test.c:6:1: warning: no semicolon at end of struct or union
    6 | } d;
      | ^
test.c: In function 'p':
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 16 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 17 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 18 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 19 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 20 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 21 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 22 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 23 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 24 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 25 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 26 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 27 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 28 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 29 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^
test.c:13:12: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   13 |     d.c[i] = b[i];
      |     ~~~~~~~^~~~~~
test.c:5:8: note: at offset 30 into destination object 'c' of size 16
    5 |   char c[LEN]
      |        ^

Compiling both the original DPDK and simplified code with -O3 for POWER systems
generates the given warnings, but compiling the code with -O2 for POWER systems
does not generate the warning.

Compiling the simplified code with either -O3 or -O2 for x86_64 systems does
not generate a warning.

             reply	other threads:[~2021-09-13 20:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 20:15 drc at linux dot vnet.ibm.com [this message]
2021-09-13 20:22 ` [Bug middle-end/102316] " pinskia at gcc dot gnu.org
2021-09-14  5:31 ` xtkoba at gmail dot com
2022-08-12  2:37 ` sergiodj at sergiodj dot net
2022-08-25  7:48 ` guihaoc at gcc dot gnu.org
2022-08-25  8:28 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102316-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).