summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc
blob: 7dbcfbd52287fc226f5c336721180d0b830af4f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 19990805 gdr
//
// XXX: to impove later.
// Origin: Andreas Amann <amann@physik.tu-berlin.de>
// CXXFLAGS: -g

#include <iostream>
#include <valarray>


int main()
{
    std::valarray<double> a(10), b(10), c(10), d(10);

    a = 1.2;
    b = 3.1;

    c = 4.0;

    d = ( 2.0 * b + a );  // works
    std::cout << "d[4] = " << d[4] << std::endl;

    d = (a * 2.0 + b ); // works
    std::cout << "d[4] = " << d[4] << std::endl;

    d = (a + b * 2.0 ); // segfaults!
    std::cout << "d[4] = " << d[4] << std::endl;
    d = (a + 2.0* b );

    std::cout << "d[4] = " << d[4] << std::endl;
    d = (a + 2.0* b );
    std::cout << "d[4] = " << d[4] << std::endl;
    d = (a + 2.0* b );

    std::cout << "d[4] = " << d[4] << std::endl;
    return 0;
}