Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.other/badopt1.C

raw
1 // { dg-do run }
2 // { dg-options "-O2" }
3 // Based on a testcase by Bryan Weston <[email protected]>
4 // egcs 1.1 fails to increment count
5
6
7 struct Base { Base() {} }; // removing the constructor fixes the problem
8 struct Derived : Base {}; // so does removing the base class
9
10 int main() {
11 int count = 0;
12 Derived* array[1]; // making this Base*[1] does not fix the problem
13 array[count++] = new Derived (); // but then new Base() does
14 if (count!=1)
15 return 1;
16 }