Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#48 a safeToReturn() issue

open
nobody
None
5
2012-08-13
2012-08-13
Sylwester Arabas
No

Hi,

The code below fails on F_safe() call while it does work with F() call:

$ cat test.cpp
#include <blitz/array.h>
using namespace blitz;
using namespace std;

template <class T1, class T2>
auto F(const T1 &a1, const T2 &a2)
-> decltype(a1 * a2)
{ return a1 * a2; }

template <class T1, class T2>
auto F_safe(const T1 &a1, const T2 &a2)
-> decltype(safeToReturn(a1 * a2))
{ return safeToReturn(a1 * a2); }

int main()
{
Range i(0, 10);
Array<double,1>
A(Range(-1, 11)),
B(Range(-1, 11)),
C(Range( 0, 11));

cerr << "F() ..." << endl;
A(i) = F(B(i), C(i));
cerr << "F_safe() ..." << endl;
A(i) = F_safe(B(i), C(i));
}

$ g++ -DBZ_DEBUG -std=c++11 test.cpp -lblitz
$ ./a.out
F() ...
F_safe() ...
/usr/local/include/blitz/bounds.h:71 Two array operands have different
lower bounds: in rank 0, the bounds are -1 and 0

a.out: /usr/local/include/blitz/bounds.h:72: static int
blitz::bounds::compute_lbound(int, int, int): Assertion `0' failed.
Aborted

HTH,
Sylwester

Discussion