Title
Are throw clauses necessary if a throw is already implied by the effects clause?
Status
tc1
Section
[structure.specifications]
Submitter
Judy Ward

Created on 2000-03-17.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The standard is somewhat inconsistent, but a failure to note a throw condition in a throws clause does not grant permission not to throw. The inconsistent wording is in a footnote, and thus non-normative. The proposed resolution from the LWG clarifies the footnote.

Date: 2010-10-21.18:28:33

Proposed resolution:

In [structure.specifications] paragraph 3, the footnote 148 attached to the sentence "Descriptions of function semantics contain the following elements (as appropriate):", insert the word "further" so that the foot note reads:

To save space, items that do not apply to a function are omitted. For example, if a function does not specify any further preconditions, there will be no "Requires" paragraph.

Date: 2000-03-17.00:00:00

Section 21.3.6.8 describes the basic_string::compare function this way:

21.3.6.8 - basic_string::compare [lib.string::compare]

int compare(size_type pos1, size_type n1,
                const basic_string<charT,traits,Allocator>&  str ,
                size_type  pos2 , size_type  n2 ) const;

-4- Returns: 

    basic_string<charT,traits,Allocator>(*this,pos1,n1).compare(
                 basic_string<charT,traits,Allocator>(str,pos2,n2)) .

and the constructor that's implicitly called by the above is defined to throw an out-of-range exception if pos > str.size(). See section [string.require] paragraph 4.

On the other hand, the compare function descriptions themselves don't have "Throws: " clauses and according to 17.3.1.3, paragraph 3, elements that do not apply to a function are omitted.

So it seems there is an inconsistency in the standard -- are the "Effects" clauses correct, or are the "Throws" clauses missing?

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1900
2010-10-21 18:28:33adminsetmessages: + msg1899
2000-03-17 00:00:00admincreate