invalid floating point operation when accessing vector element

M

marko.suonpera

I'm using the Newmat library where element access in ColumnVector type
is defined as follows:

typedef double Real;

Real& ColumnVector::eek:perator()(int m)
{
REPORT
if (m<=0 || m> nrows) Throw(IndexException(m,*this));
return store[m-1];
}

Real ColumnVector::eek:perator()(int m) const
{
REPORT
if (m<=0 || m> nrows) Throw(IndexException(m,*this));
return store[m-1];
}

(store is a Real* )

Now I call a function with columnvector argument:

ColumnVector a;

//set values of a
//....

double temp = a(1);
func(a);

void func(const ColumnVector &a)
{
double temp = a(1); //invalid floating point operation
}

The first element access double temp = a(1) in the calling function
works ok. In function func() this causes invalid floating point
operation. The message says "Project XXX raised exception class
C0000092 with message "floating point stack check at 0x429191."
Process stopped." If I check the contents of ColumnVector::store with
the debugger, it shows the correct value without problems.

However, if I change the function definition to without const: void
func(ColumnVector &a), it works ok. Also there are other functions of
similar type (with const definition), which work ok. What would cause
this problem?

BR, Marko
 
M

marko.suonpera

And to be more exact the exception is thrown on the line

return store[m-1];
 
M

marko.suonpera

Ok, this seems to have been caused by the previous function, which
should have returned a double but didn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top