Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-09-17 07:55:42

> > There is a historical avoidance of assert() in Boost, due to possible
> > violations. However, I believe that the new Jam build system removes
> > of) this hesitance by building both debug and release versions of the
> > library. It's still possible to shoot yourself in the foot, but it's
> > likely.
> Pardon my ignorance, but what is an "ODR violation"?

ODR stands for "One Definition Rule" (see section 3.2 in the Standard).

The problem it causes for header-file libraries is if there exists in a
header some function f() that has an assert:
  template <typename T> void f(T x) { assert(x != 0); }

then if the user has a source file that calls f() and that is compiled with
NDEBUG, and another source file that calls f() and that isn't compiled with
NDEBUG, and links them together, you get: undefined behaviour (without a

I've never dealt with ODR violations myself, but I've heard rumors of some
nasty debugging tales from others...

It was eventually decided (after many discussions on the list) to use
assert()'s in Boost, but to document the possibility of ODR violations.


For more info on ODR violations with templates:
  ISO/IEC One Definition Rule: [3.2/5]
  The C++ Programming Language (Stroustrup): []
  Boost plays with developing ODR-safe assert() replacement (never got it to
  Boost has *long* discussion on pro's and con's of assert() and assert()

Boost list run by bdawes at, gregod at, cpdaniel at, john at