Bug 104088 - [12/13/14 Regression] '-O2' (or higher) GCN offloading (only) 'libgomp.oacc-c-c++-common/vprop.c' excess errors: 'warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]'
Summary: [12/13/14 Regression] '-O2' (or higher) GCN offloading (only) 'libgomp.oacc-c...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 12.0
: P2 normal
Target Milestone: 12.4
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, openacc
Depends on:
Blocks: Wstringop-overflow
  Show dependency treegraph
 
Reported: 2022-01-18 10:24 UTC by Thomas Schwinge
Modified: 2024-03-22 14:06 UTC (History)
7 users (show)

See Also:
Host:
Target: gcn
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-03-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schwinge 2022-01-18 10:24:43 UTC
The recent commit r12-6592-g72332337e3d8acbb21398b8d123f1bfe77a8327e "Use enclosing object size if it's smaller than member [PR 101475]" causes a regression with '-O2' (or higher) GCN offloading (only):

    PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O0  (test for excess errors)
    PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O0  execution test
    [-PASS:-]{+FAIL:+} libgomp.oacc-c/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  (test for excess errors)
    PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  execution test

    In function 'test_char._omp_fn.0':
    lto1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
    lto1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

    PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O0  (test for excess errors)
    PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O0  execution test
    [-PASS:-]{+FAIL:+} libgomp.oacc-c++/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  (test for excess errors)
    PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/vprop.c -DACC_DEVICE_TYPE_radeon=1 -DACC_MEM_SHARED=0 -foffload=amdgcn-amdhsa  -O2  execution test

    In function '_Z9test_charv._omp_fn.0':
    lto1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
    lto1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

There is no (!) meaningful difference if good vs. bad '-foffload=amdgcn-amdhsa=-fdump-tree-all\ -fdump-ipa-all\ -fdump-rtl-all' dump files.

I'm happy to supply any dump files etc. to help resolve this.
Comment 1 Thomas Schwinge 2022-03-21 15:54:45 UTC
For the record: I thought it was worth a quick try, but Jakub's recent commit r12-7713-g32ca611c42658948f1b8883994796f35e8b4e74d "Allow (void *) 0xdeadbeef accesses without warnings [PR99578]" does not resolve this issue here.
Comment 2 Jakub Jelinek 2022-05-06 08:32:21 UTC
GCC 12.1 is being released, retargeting bugs to GCC 12.2.
Comment 3 Richard Biener 2022-08-19 08:25:24 UTC
GCC 12.2 is being released, retargeting bugs to GCC 12.3.
Comment 4 Richard Biener 2022-10-19 09:48:55 UTC
Doesn't reproduce without actually doing offloading
Comment 5 Tobias Burnus 2022-11-21 13:18:46 UTC
I did have a look at this the other day. If I recall correctly, the issue was that

  tree destsize = compute_objsize (dest, stmt, ostype, &aref, &ptr_qry);

in strlen_pass::maybe_warn_overflow (in file tree-ssa-strlen.cc) wrongly returned 0
for a   var[i]._char_memb. Somewhere ('var'?) was a variable which did not use the 64bit generic memory space but a 32-byte one. My feeling is that the problem is related to having a non-generic memory space.

(Disclaimer: It was a couple of days back when I had a quick look and I might misremember. The 'var[i]._char_memb' matches pattern wise but the name was surely different.)

However, reading now the commit message title, quoted in comment 0 - "Use enclosing object size if it's smaller than member" -, explains why the 1-byte character type's length is not used even if it looks fine.
Comment 6 Richard Biener 2023-05-08 12:23:34 UTC
GCC 12.3 is being released, retargeting bugs to GCC 12.4.