Boost logo

Boost :

Subject: Re: [boost] [system] Undocumented deprecated throws variable + run-time error
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-10-19 19:33:24

----- Original Message -----
From: "vicente.botet" <vicente.botet_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, October 19, 2010 9:16 PM
Subject: [boost] [system] Undocumented deprecated throws variable

Hi Beman,

The documentation doesn't states explicitly that the throws variable is deprecated (see section "Deprecated names"). In addition the section "Semantics of throws object" explaining how this variable should be used must be rewritten to show the usage of the function throws().

Could this be changed for 1.45?


More in the throws() function.

In principle, when I check if an error_code is the throws error_code I'm doing like follows

void f(system::error_code& ec) {
    if (&ec == &boost::throws()) {
        // throw an exception
    } else {
        // update the ec

When I do that I get run-time errors.

I have changed the throws function so instead of returning a 0 returns a pointer to a static variable and check that the value of the variable don't change. Then all works again.

  namespace detail {
      inline system::error_code * throws() {
#if 1
        static system::error_code throws_(0x1234, system::generic_category());
        return &throws_;
        return 0;
    // Misuse of the error_code object is turned into a noisy failure by
    // poisoning the reference. This particular implementation doesn't
    // produce warnings or errors from popular compilers, is very efficient
    // (as determined by inspecting generated code), and does not suffer
    // from order of initialization problems. In practice, it also seems
    // cause user function error handling implementation errors to be detected
    // very early in the development cycle.
  inline system::error_code & throws()
    { return *detail::throws(); }

Am I doing something wrong?

BTW, I have not found any test that uses the throws() function, so I have no had the possibility to see how to use it and if check if this works now.

Please, could you help me?


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