From 85e5e340bed7df53a521af7e578d7faf830f40c1 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 13 Jul 2010 13:31:26 +0000 Subject: [PATCH] re PR c++/36960 (Reference variable in virtually inherited base corrupted under optimization) 2010-07-13 Richard Guenther PR tree-optimization/36960 * g++.dg/torture/pr36960.C: New testcase. From-SVN: r162141 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr36960.C | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr36960.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 186a4c613f4..fe67559ae1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-13 Richard Guenther + + PR tree-optimization/36960 + * g++.dg/torture/pr36960.C: New testcase. + 2010-07-13 Paolo Carlini PR c++/44908 diff --git a/gcc/testsuite/g++.dg/torture/pr36960.C b/gcc/testsuite/g++.dg/torture/pr36960.C new file mode 100644 index 00000000000..280a6755d95 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr36960.C @@ -0,0 +1,22 @@ +// { dg-do run } + +struct Lower { + const int& ref; + Lower(const int& ref) : ref(ref) { } +}; +struct Middle : public virtual Lower { + Middle(const int& ref) : Lower(ref) { } +}; +struct Upper : public Middle { + Upper(const int& ref) : Lower(ref), Middle(ref) { } + int get() { return ref; } +}; +extern "C" void abort (void); +int main() +{ + int i = 0; + Upper upper(i); + if (upper.get() != 0) + abort (); + return 0; +}