https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125912
Bug ID: 125912
Summary: -Warray-bounds and -Wstringop-overflow false positives
Product: gcc
Version: 16.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: edoardo762 at gmail dot com
Target Milestone: ---
Created attachment 64811
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64811&action=edit
error log
This code piece of code
#include <vector>
struct Test {
std::vector<unsigned char> data;
void set() {
data.resize(1);
}
};
Test returns;
void a(){
returns.set();
}
Triggers a false positive "-Warray-bounds=" if compiled with the flags "-O3
-Wall" and a false positive "-Wstringop-overflow=" if compiled with the flags
"-O3 -Wextra".
This is a goldbot repro showing the bug https://godbolt.org/z/6zYE4bxhM.
Attached are the warnings generated.