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 
Aint()17 Aint::Aint () {}
~Aint()18 Aint::~Aint () {}
19 
20 static int count;
21 
22 template <class T>
23 struct A
24 {
25   unsigned Blksize() const;
26 
fA27   void f()
28   {
29     new T[Blksize()];
30   }
31 };
32 
Blksize()33 template <class T> unsigned A<T>::Blksize () const
34 {
35   count++;
36   return 1;
37 }
38 
main()39 int main ()
40 {
41   A<Aint> a;
42   a.f();
43 
44   return count != 1;
45 }
46