Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
26.valarray.transcend.stdcxx-315.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <cstdio>
31#include <cstdlib>
32#include <cstring>
33#include <new>
34#include <valarray>
35
36void* operator new (std::size_t s) throw (std::bad_alloc)
37{
38 return std::memset (std::malloc (s), 0x55, s);
39}
40
41bool pass = true;
42
43struct S {
44 const S* const self;
45 S (): self (this) { }
46 S (const S &s): self (this) { pass = pass && &s == s.self; }
47 S (double): self (this) { }
48 ~S () { pass = pass && this == self; }
49 operator double () const { pass = pass && this == self; return 1.0; }
50
51 void operator=(const S &s) {
52 pass = pass && &s == s.self && this == self;
53 }
54 S operator- () const { pass = pass && this == self; return *this; }
55 bool operator< (const S &s) const {
56 pass = pass && &s == s.self && this == self;
57 return false;
58 }
59};
60
61
62int main ()
63{
64 const S s;
65 const std::valarray<S> a (2);
66
67 int nfails = 0;
68
69#define TEST(fun, args) \
70 pass = true; \
71 fun args; \
72 if (!pass) { \
73 std::fprintf (stderr, "std::%s uses uninitialized storage\n", \
74 #fun); \
75 ++nfails; \
76 } (void)0
77
78TEST (abs, (a));
79 TEST (acos, (a));
80 TEST (asin, (a));
81 TEST (atan, (a));
82 TEST (atan2, (a, a));
83 TEST (atan2, (a, s));
84 TEST (atan2, (s, a));
85 TEST (cos, (a));
86 TEST (cosh, (a));
87 TEST (exp, (a));
88 TEST (log, (a));
89 TEST (log10, (a));
90 TEST (pow, (a, a));
91 TEST (pow, (a, s));
92 TEST (pow, (s, a));
93 TEST (sin, (a));
94 TEST (sinh, (a));
95 TEST (sqrt, (a));
96 TEST (tan, (a));
97 TEST (tanh, (a));
98
99 assert (0 == nfails);
100
101 return 0;
102}
#define a
Definition 17.names.cpp:109
#define s
const minus< T > & operator-(const minus< T > &lhs, const minus< T > &rhs)
#define TEST(fun, args)
T abs(T t)
#define assert(expr)
Definition _cassert.h:40
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14787
void operator=(const S &s)
const S *const self