diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b2db604b467..bcdbbddd3c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-04-26 Richard Guenther + Daniel Berlin + + PR tree-optimization/30567 + * g++.dg/other/pr30567.C: New testcase. + 2007-04-26 Richard Guenther PR tree-optimization/31703 diff --git a/gcc/testsuite/g++.dg/other/pr30567.C b/gcc/testsuite/g++.dg/other/pr30567.C new file mode 100644 index 00000000000..626d27bb386 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr30567.C @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O -finline-functions -fstrict-aliasing" } */ + +template +struct const_ref +{ + const T* begin; + const_ref(const T* b) : begin(b) {} +}; + +template +T sum(const_ref const& a) +{ + T result = 0; + for(unsigned i=0;i<1;i++) result += a.begin[i]; + return result; +} + +struct tiny_plain +{ + int elems[2]; + tiny_plain() { elems[0]=1; } +}; + +struct vec3 : tiny_plain {}; + +struct mat3 +{ + int type() const { return sum(const_ref(vec3().elems)) == 1; } +}; + +int main() { return mat3().type() ? 0 : 1; } +