Title
Some problems with classes error_code/error_condition
Status
cd1
Section
[syserr]
Submitter
Daniel Krügler

Created on 2008-02-24.00:00:00 last changed 163 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Resolution of part A:

Change [syserr.errcode.overview] Class error_code overview synopsis as indicated:

private:
  int val_;                    // exposition only
  const error_category&* cat_; // exposition only

Change [syserr.errcode.constructors] Class error_code constructors as indicated:

error_code();

Effects: Constructs an object of type error_code.

Postconditions: val_ == 0 and cat_ == &system_category.

Throws: Nothing.

error_code(int val, const error_category& cat);

Effects: Constructs an object of type error_code.

Postconditions: val_ == val and cat_ == &cat.

Throws: Nothing.

Change [syserr.errcode.modifiers] Class error_code modifiers as indicated:

void assign(int val, const error_category& cat);

Postconditions: val_ == val and cat_ == &cat.

Throws: Nothing.

Change [syserr.errcode.observers] Class error_code observers as indicated:

const error_category& category() const;

Returns: *cat_.

Throws: Nothing.

Change [syserr.errcondition.overview] Class error_condition overview synopsis as indicated:

private:
  int val_;                    // exposition only
  const error_category&* cat_; // exposition only

Change [syserr.errcondition.constructors] Class error_condition constructors as indicated:

(If the proposed resolution of issue 805 has already been applied, the name posix_category will have been changed to generic_category. That has no effect on this resolution.)
error_condition();

Effects: Constructs an object of type error_condition.

Postconditions: val_ == 0 and cat_ == &posix_category.

Throws: Nothing.

error_condition(int val, const error_category& cat);

Effects: Constructs an object of type error_condition.

Postconditions: val_ == val and cat_ == &cat.

Throws: Nothing.

Change [syserr.errcondition.modifiers] Class error_condition modifiers as indicated:

void assign(int val, const error_category& cat);

Postconditions: val_ == val and cat_ == &cat.

Throws: Nothing.

Change [syserr.errcondition.observers] Class error_condition observers as indicated:

const error_category& category() const;

Returns: *cat_.

Throws: Nothing.

Resolution of part C:

In [syserr.errcat.virtuals], remove the throws clause p. 10.

virtual string message(int ev) const = 0;

Returns: A string that describes the error condition denoted by ev.

Throws: Nothing.

In [syserr.errcode.observers], remove the throws clause p. 8.

string message() const;

Returns: category().message(value()).

Throws: Nothing.

In [syserr.errcondition.observers], remove the throws clause p. 6.

string message() const;

Returns: category().message(value()).

Throws: Nothing.

Date: 2010-10-21.18:28:33

[ Sophia Antipolis: ]

Part A: NAD (editorial), cleared by the resolution of issue 832.

Part B: Technically correct, save for typo. Rendered moot by the concept proposal (N2620) NAD (editorial).

Part C: We agree; this is consistent with the resolution of issue 721.

Howard: please ping Beman, asking him to clear away parts A and B from the wording in the proposed resolution, so it is clear to the editor what needs to be applied to the working paper.

Beman provided updated wording. Since issue 832 is not going forward, the provided wording includes resolution of part A.

Date: 2008-02-24.00:00:00
  1. [syserr.errcode.overview]/1, class error_code and [syserr.errcondition.overview]/, class error_condition synopses declare an expository data member cat_:

    const error_category& cat_; // exposition only
    

    which is used to define the semantics of several members. The decision to use a member of reference type lead to several problems:

    1. The classes are not (Copy)Assignable, which is probably not the intent.
    2. The post conditions of all modifiers from [syserr.errcode.modifiers] and [syserr.errcondition.modifiers], resp., cannot be fulfilled.

    The simple fix would be to replace the reference by a pointer member.

  2. I would like to give the editorial remark that in both classes the constrained operator= overload (template with ErrorCodeEnum argument) makes in invalid usage of std::enable_if: By using the default value for the second enable_if parameter the return type would be defined to be void& even in otherwise valid circumstances - this return type must be explicitly provided (In error_condition the first declaration uses an explicit value, but of wrong type).
  3. The member function message throws clauses ( [syserr.errcat.virtuals]/10, [syserr.errcode.observers]/8, and [syserr.errcondition.observers]/6) guarantee "throws nothing", although they return a std::string by value, which might throw in out-of-memory conditions (see related issue 771).
History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3835
2010-10-21 18:28:33adminsetmessages: + msg3834
2008-02-24 00:00:00admincreate