Boost logo

Boost :

From: Kresimir Fresl (fresl_at_[hidden])
Date: 2002-09-13 02:38:12


Toon Knapen wrote:

> the bounds checking mechanism throws an exception instead of performing an
> assert. But I have no clue how I can ask my debugger where the exception was
> thrown so I would prefer an assert() to be used. In the debugger, it's then
> easy to perform a stack_trace.

Did you try to define BOOST_NO_EXCEPTIONS ?

raise() functions of all exception classes in `ublas/exception.hpp'
are defined as:

         virtual void raise () {
   #ifndef BOOST_NO_EXCEPTIONS
             throw *this;
   #else
             abort ();
   #endif
         }

So, with BOOST_NO_EXCEPTIONS defined nothing is thrown:
==============================================
   #include <iostream>
   #include <ublas/vector.hpp>

   int main() {
     boost::numeric::ublas::vector<double> ux (8);
     try {
        std::cout << ux[8] << std::endl;
     }
     catch (...) {
        std::cout << "here we are" << std::endl;
     }
   }
==============================================

When compiled without -DBOOST_NO_EXCEPTIONS (and, of
course, without -DNDEBUG ;o), output is:

   Assertion failed in file
/home/krcko/include/boost/numeric/ublas/storage.hpp at line 137:
   i < size_
   here we are

With -DBOOST_NO_EXCEPTIONS output is:

   Assertion failed in file
/home/krcko/include/boost/numeric/ublas/storage.hpp at line 137:
   i < size_
   Aborted

(My compiler is g++ 3.2.)

Sincerely,

fres


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk