Debian Codegraph @

gcc/testsuite/g++.dg/warn/Warray-bounds-26.C

raw
1 /* PR middle-end/101600 - Spurious -Warray-bounds downcasting a polymorphic
2 pointer
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
5
6 struct S1 { virtual ~S1(); };
7 struct S2 { int m; };
8 struct S3 { virtual ~S3(); };
9 struct S4: S1, S2, S3 {};
10
11 int f1 ();
12
13 void f2 (S3 *);
14
15 void f3 (S2 *p)
16 {
17 for (int i = f1 (); f1 (); )
18 {
19 if (i == 0)
20 {
21 p = 0;
22 break;
23 }
24 }
25
26 f2 (static_cast<S4 *>(p)); // { dg-bogus "-Warray-bounds" }
27 }