https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98083
Bug ID: 98083 Summary: [11 regression] -Warray-bounds false positive with virtual derivation Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: s...@li-snyder.org Target Milestone: --- With gcc 11 (20201128), the following fragment gives a bogus warning when compiled with -Wall -O2: -- x.cc --------------------------------------------------------- struct base1 { virtual ~base1(); }; struct base2 { virtual ~base2(); }; class base3 : public base2, public virtual base1 {}; class istream_tie : public virtual base1, public virtual base3 { }; void foo() { istream_tie in; } ----------------------------------------------------------------- $ g++ -c -Wall -O2 x.cc x.cc: In function ‘void foo()’: x.cc:13:7: warning: array subscript ‘base3[0]’ is partly outside array bounds of ‘istream_tie [1]’ [-Warray-bounds] 13 | class istream_tie : | ^~~~~~~~~~~ x.cc:21:15: note: while referencing ‘in’ 21 | istream_tie in; | ^~ x.cc:11:7: warning: array subscript ‘base3[0]’ is partly outside array bounds of ‘istream_tie [1]’ [-Warray-bounds] 11 | class base3 : public base2, public virtual base1 {}; | ^~~~~ x.cc:21:15: note: while referencing ‘in’ 21 | istream_tie in; | ^~ This looks particularly funny since the input source does not anywhere use array indexing. But this appears to have something to do with the use of virtual derivation.