Bug 110051 - error: writing 1 byte into a region of size 0
Summary: error: writing 1 byte into a region of size 0
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 13.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wstringop-overflow
  Show dependency treegraph
 
Reported: 2023-05-31 08:05 UTC by Felix
Modified: 2024-02-22 10:47 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-05-31 00:00:00


Attachments
build log (2.28 KB, text/plain)
2023-05-31 08:05 UTC, Felix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Felix 2023-05-31 08:05:55 UTC
Created attachment 55220 [details]
build log

Hello,

I am compiling some software with use of GCC, there are many errors which are not dependent on the code being compiled, since the logs seem to point at the errors in the files within /usr directory:

/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/bits/stl_algobase.h:398:17: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  398 |         { *__to = *__from; }
      |           ~~~~~~^~~~~~~~~

I use Gentoo Linux, my current gcc version  is 13.1.1_p20230520 which I installed with the system package manager (portage).

I also attach a full log of compilation of a package (I need to build multiple packages in a chain, when I skip this one there arise similar errors at compilation process of subsequent packages).
Comment 1 Richard Biener 2023-05-31 08:56:28 UTC
The diagnostics are from template instantiations of the standard template library which we now consider useful to the user.  They will necessarily
point to implementation details of that library, a better reporting is
difficult to implement.
Comment 2 Jonathan Wakely 2023-05-31 09:39:06 UTC
(In reply to Felix from comment #0)
> I am compiling some software with use of GCC, there are many errors which

Those are warnings. You requested to turn them into errors with -Werror.

> are not dependent on the code being compiled, since the logs seem to point
> at the errors in the files within /usr directory:

This is an incorrect assumption.

If you write the following code, you'll get diagnostics pointing to the standard library code, but the bug is still in your code:

  char s1[] = "abcdefghij";
  char s2[5];
  std::copy(std::begin(s1), std::end(s1), s2);

In your specific case, it might be a false positive warning. But you can't assume that just because the diagnostics show code in the std::lib.

The build log is useless though. All it shows is there are some warnings, nobody can tell if they're valid or not without the code. Please read https://gcc.gnu.org/bugs again and provide the requested info. Also please search the (many!) existing bugs about -Wstringop-overflow warnings and check if yours is another duplicate of one of those.
Comment 3 Felix 2023-06-01 15:52:26 UTC
Yes, you're right, the warning is turned to error.

Without this option the compilation runs normally
Comment 4 Andrew Pinski 2024-02-21 00:29:21 UTC
No testcase in over 6 months so closing as invalid.