public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108366] New: [12/13 Regression] Spurious stringop overflow, possibly alias-related
@ 2023-01-11  0:18 BenWiederhake.GitHub at gmx dot de
  2023-01-11  0:23 ` [Bug tree-optimization/108366] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: BenWiederhake.GitHub at gmx dot de @ 2023-01-11  0:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108366
           Summary: [12/13 Regression] Spurious stringop overflow,
                    possibly alias-related
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: BenWiederhake.GitHub at gmx dot de
  Target Milestone: ---

Created attachment 54241
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54241&action=edit
Minimal C++ file that reproduces the bug

This seems similar but different from #107852.

Starting with gcc 12 and continuing into the current trunk (git aa966d54ee4),
the compiler emits a stringop overflow warning.

In addition to the attachment: https://godbolt.org/z/3xorbqsha

I would expect either of the following behaviors:
- In line 20 (marked with "// !!!"), the compiler sees that even if `new`
returned a nullptr for any reason, if execution continues in the make_vector()
function, it can now assume that new_buffer is non-null, and therefore memset
is safe.
- Alternatively, if the compiler cannot deduce that, then the warning should
not be generated, since the compiler cannot now what pointer will be returned
by data().

gcc trunk (git aa966d54ee4) → spurious warning
gcc 12.2.0 (Debian 12.2.0-13) → spurious warning
gcc 11.3.0 (Debian 11.3.0-10) → no warning
gcc 10.4.0 (Debian 10.4.0-6) → no warning
clang 13 and 14 → no warning

system type: Debian testing, x86_64
options during configure:
Debian gcc reports: ../src/configure -v --with-pkgversion='Debian 12.2.0-13'
--with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-PBog5r/gcc-12-12.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-PBog5r/gcc-12-12.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
When I manually built it I used this:
../gcc-src/configure --enable-shared --disable-werror --enable-languages=c,c++
--enable-default-pie --enable-lto --enable-threads=posix
--enable-initfini-array --with-linker-hash-style=gnu --disable-multilib
complete commandline that triggers the bug: g++ -O2 -o foo repro.cpp

compiler error message:
```
In function ‘Vector make_vector()’,
    inlined from ‘int main()’ at repro.cpp:36:31:
repro.cpp:27:11: warning: ‘void* memset(void*, int, size_t)’ writing 128 bytes
into a region of size 40 overflows the destination [-Wstringop-overflow=]
   27 |     memset(buffer.data(), 'A', new_size);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
repro.cpp: In function ‘int main()’:
repro.cpp:36:10: note: destination object ‘actual’ of size 40
   36 |     auto actual = make_vector();
      |          ^~~~~~
```

preprocessed file (*.i*) that triggers the bug: See next comments, I can't
figure out how to put more than one attachment in a single comment.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-08 12:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11  0:18 [Bug c++/108366] New: [12/13 Regression] Spurious stringop overflow, possibly alias-related BenWiederhake.GitHub at gmx dot de
2023-01-11  0:23 ` [Bug tree-optimization/108366] " pinskia at gcc dot gnu.org
2023-01-11  0:23 ` BenWiederhake.GitHub at gmx dot de
2023-01-11  0:25 ` BenWiederhake.GitHub at gmx dot de
2023-01-11 10:45 ` [Bug tree-optimization/108366] [12/13 Regression] Spurious stringop overflow, possibly alias-related since r12-145-gd1d01a66012a93cc marxin at gcc dot gnu.org
2023-01-11 12:34 ` rguenth at gcc dot gnu.org
2023-02-21 13:17 ` rguenth at gcc dot gnu.org
2023-05-08 12:26 ` [Bug tree-optimization/108366] [12/13/14 " rguenth at gcc dot gnu.org

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).