OSDN Git Service

2011-02-20 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / template / new1.C
1 // { dg-do run }
2 // { dg-options "-O2" }
3
4 // Copyright (C) 2004 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 2 Dec 2004 <nathan@codesourcery.com>
6
7 // PR 18318. ICE with template new[]
8 // Origin:Elliot Hughes <enh@jessies.org>
9 // Andrew Pinski <pinskia@gcc.gnu.org>
10
11 struct Aint
12 {
13   ~Aint ();
14   Aint ();
15 };
16
17 Aint::Aint () {}
18 Aint::~Aint () {}
19
20 static int count;
21
22 template <class T>
23 struct A
24 {
25   unsigned Blksize() const;
26   
27   void f()
28   {
29     new T[Blksize()];
30   }
31 };
32
33 template <class T> unsigned A<T>::Blksize () const
34 {
35   count++;
36   return 1;
37 }
38
39 int main ()
40 {
41   A<Aint> a;
42   a.f();
43   
44   return count != 1;
45 }