invalid floating point operation when accessing vector element

Discussion in 'C++' started by marko.suonpera@24net.zzn.com, Jan 5, 2007.

  1. Guest

    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
     
    , Jan 5, 2007
    #1
    1. Advertising

  2. Guest

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

    return store[m-1];
     
    , Jan 5, 2007
    #2
    1. Advertising

  3. Guest

    Ok, this seems to have been caused by the previous function, which
    should have returned a double but didn't.
     
    , Jan 5, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sunil Shukla

    floating point operation in VHDL

    Sunil Shukla, Sep 1, 2004, in forum: VHDL
    Replies:
    1
    Views:
    640
    ALuPin
    Sep 2, 2004
  2. Replies:
    8
    Views:
    1,962
    Csaba
    Feb 18, 2006
  3. jawilson
    Replies:
    2
    Views:
    867
    jawilson
    Feb 19, 2006
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,373
    Saraswati lakki
    Jan 6, 2012
  5. teeshift
    Replies:
    2
    Views:
    274
    Chris Pearl
    Dec 1, 2006
Loading...

Share This Page