]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/53581 (Segmentation fault when enabling -std=c++0x on template code)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 14 Oct 2012 18:24:32 +0000 (18:24 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 14 Oct 2012 18:24:32 +0000 (18:24 +0000)
2012-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53581
* g++.dg/template/crash113.C: New.

From-SVN: r192438

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash113.C [new file with mode: 0644]

index 79aee2f3d6e317731a7a0f5500525f5ca2e95958..f8b04d2d5dcafc294b7a4786b87bf2ae888f2f39 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53581
+       * g++.dg/template/crash113.C: New.
+
 2012-10-14  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/unroll_5.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/template/crash113.C b/gcc/testsuite/g++.dg/template/crash113.C
new file mode 100644 (file)
index 0000000..3d3a562
--- /dev/null
@@ -0,0 +1,50 @@
+// PR c++/53581
+
+template<class A, int M, int N>
+class Child;
+
+template<class A, int M, int N>
+class Base
+{
+public:
+  Child<A, M, N> operator-(const Base<A, M, N> &m) const
+  {
+    Child<A, M, N> diff;
+    return diff;
+  }
+
+  A test() const
+  {
+    return 0;
+  }
+
+private:
+  A values[M * N];
+};
+
+template<class A, int N>
+class Ops
+{
+public:
+  virtual ~Ops() {}
+
+  bool bar() const
+  {
+    Child<A, N, N> mat;
+    return (*static_cast<const Child<A, N, N>*>(this) - mat).test();
+  }
+};
+
+
+template<class A, int N>
+class Child<A, N, N> : public Base<A, N, N>, public Ops<A, N> {};
+
+class ImageWarp
+{
+  bool bar() const
+  {
+    return foo.bar();
+  }
+
+  Child<float, 3, 3> foo;
+};