Merge from mainline (163495:164578).
[official-gcc/graphite-test-results.git] / gcc / testsuite / g++.dg / torture / pr44972.C
blobe409148da1c32c0df89d8291b1088fd847a8a385
1 /* { dg-do compile } */
3 #include<cassert>
4 #include<new>
5 #include<utility>
7 namespace boost {
9 template<class T>
10 class optional;
12 class aligned_storage
14         char data[ 1000 ];
15   public:
16     void const* address() const { return &data[0]; }
17     void      * address()       { return &data[0]; }
18 } ;
21 template<class T>
22 class optional_base
24   protected :
25     optional_base(){}
26     optional_base ( T const& val )
27     {
28       construct(val);
29     }
31     template<class U>
32     void assign ( optional<U> const& rhs )
33     {
34       if (!is_initialized())
35         if ( rhs.is_initialized() )
36           construct(T());
37     }
39   public :
41     bool is_initialized() const { return m_initialized ; }
43   protected :
45     void construct ( T const& val )
46      {
47        new (m_storage.address()) T(val) ;
48      }
50     T const* get_ptr_impl() const
51     { return static_cast<T const*>(m_storage.address()); }
53   private :
55     bool m_initialized ;
56     aligned_storage  m_storage ;
57 } ;
60 template<class T>
61 class optional : public optional_base<T>
63     typedef optional_base<T> base ;
65   public :
67     optional() : base() {}
68     optional ( T const& val ) : base(val) {}
69     optional& operator= ( optional const& rhs )
70       {
71         this->assign( rhs ) ;
72         return *this ;
73       }
75     T const& get() const ;
77     T const* operator->() const { assert(this->is_initialized()) ; return this->get_ptr_impl() ; }
79 } ;
82 } // namespace boost
85 namespace std
88   template<typename _Tp, std::size_t _Nm>
89     struct array
90     {
91       typedef _Tp                                     value_type;
92       typedef const value_type*                       const_iterator;
94       value_type _M_instance[_Nm];
96     };
100 class NT
102   double _inf, _sup;
106 template < typename T > inline
107 std::array<T, 1>
108 make_array(const T& b1)
110   std::array<T, 1> a = { { b1 } };
111   return a;
114 class V
116   typedef std::array<NT, 1>               Base;
117   Base base;
119 public:
120   V() {}
121   V(const NT &x)
122     : base(make_array(x)) {}
126 using boost::optional ;
128 optional< std::pair< NT, NT > >
129   linsolve_pointC2() ;
131 optional< V > construct_normal_offset_lines_isecC2 ( )
133   optional< std::pair<NT,NT> > ip;
135   ip = linsolve_pointC2();
137   V a(ip->first) ;
138   return a;