This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TC1 status.

### 222. Are throw clauses necessary if a throw is already implied by the effects clause?

Section: 16.3.2.4 [structure.specifications] Status: TC1 Submitter: Judy Ward Opened: 2000-03-17 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [structure.specifications].

View all other issues in [structure.specifications].

View all issues with TC1 status.

Discussion:

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 21.3.3.2 [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?

Proposed resolution:

In 16.3.2.4 [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.

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.