diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/torture/pr44972.C | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/torture/pr44972.C')
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr44972.C | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/torture/pr44972.C b/gcc/testsuite/g++.dg/torture/pr44972.C new file mode 100644 index 000000000..e409148da --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr44972.C @@ -0,0 +1,142 @@ +/* { dg-do compile } */ + +#include<cassert> +#include<new> +#include<utility> + +namespace boost { + +template<class T> +class optional; + +class aligned_storage +{ + char data[ 1000 ]; + public: + void const* address() const { return &data[0]; } + void * address() { return &data[0]; } +} ; + + +template<class T> +class optional_base +{ + protected : + optional_base(){} + optional_base ( T const& val ) + { + construct(val); + } + + template<class U> + void assign ( optional<U> const& rhs ) + { + if (!is_initialized()) + if ( rhs.is_initialized() ) + construct(T()); + } + + public : + + bool is_initialized() const { return m_initialized ; } + + protected : + + void construct ( T const& val ) + { + new (m_storage.address()) T(val) ; + } + + T const* get_ptr_impl() const + { return static_cast<T const*>(m_storage.address()); } + + private : + + bool m_initialized ; + aligned_storage m_storage ; +} ; + + +template<class T> +class optional : public optional_base<T> +{ + typedef optional_base<T> base ; + + public : + + optional() : base() {} + optional ( T const& val ) : base(val) {} + optional& operator= ( optional const& rhs ) + { + this->assign( rhs ) ; + return *this ; + } + + T const& get() const ; + + T const* operator->() const { assert(this->is_initialized()) ; return this->get_ptr_impl() ; } + +} ; + + +} // namespace boost + + +namespace std +{ + + template<typename _Tp, std::size_t _Nm> + struct array + { + typedef _Tp value_type; + typedef const value_type* const_iterator; + + value_type _M_instance[_Nm]; + + }; +} + + +class NT +{ + double _inf, _sup; +}; + + +template < typename T > inline +std::array<T, 1> +make_array(const T& b1) +{ + std::array<T, 1> a = { { b1 } }; + return a; +} + +class V +{ + typedef std::array<NT, 1> Base; + Base base; + +public: + V() {} + V(const NT &x) + : base(make_array(x)) {} + +}; + +using boost::optional ; + +optional< std::pair< NT, NT > > + linsolve_pointC2() ; + +optional< V > construct_normal_offset_lines_isecC2 ( ) +{ + optional< std::pair<NT,NT> > ip; + + ip = linsolve_pointC2(); + + V a(ip->first) ; + return a; +} + + + |