Issue2069

Title 2069. Inconsistent exception spec for basic_string move constructor
Status open Section [string.cons]
Submitter Bo Persson

Created on 2011-07-01.00:00:00 by admin, last changed by admin.

Messages
msg5714 (view) Date: 2011-08-16.23:35:18

Proposed resolution:

This wording is relative to the FDIS.

  1. Change [string.cons] p3 as indicated (This move constructor has a wide contract and is therefore safely marked as noexcept):

    basic_string(const basic_string<charT,traits,Allocator>& str);
    basic_string(basic_string<charT,traits,Allocator>&& str) noexcept;
    

    -2- Effects: Constructs an object of class basic_string as indicated in Table 64. In the second form, str is left in a valid state with an unspecified value.

    -3- Throws: The second form throws nothing if the allocator's move constructor throws nothing.

  2. Change [string.cons] p18 as indicated (This move-like constructor may throw, if the allocators don't compare equal, but not because of a potentially throwing allocator copy constructor, only because the allocation attempt may fail and throw an exception):

    basic_string(const basic_string& str, const Allocator& alloc);
    basic_string(basic_string&& str, const Allocator& alloc);
    

    […]

    -18- Throws: The second form throws nothing if alloc == str.get_allocator() unless the copy constructor for Allocator throws.

msg5692 (view) Date: 2011-08-16.23:35:18

[ 2011 Bloomington. ]

Move to Ready.

msg5691 (view) Date: 2011-07-11.00:00:00

[ 2011-07-11: Daniel comments and suggests wording changes ]

Further, according to paragraph 18 of the same sub-clause:

basic_string(const basic_string& str, const Allocator& alloc);
basic_string(basic_string&& str, const Allocator& alloc);

[…]

-18- Throws: The second form throws nothing if alloc == str.get_allocator() unless the copy constructor for Allocator throws.

The constraint "unless the copy constructor for Allocator throws" is redundant, because according to Table 28 — Allocator requirements, the expressions

X a1(a);
X a(b);

impose the requirement: "Shall not exit via an exception".

msg5690 (view) Date: 2011-07-01.00:00:00

Sub-clause [string.cons] contains these constructors in paragraphs 2 and 3:

basic_string(const basic_string<charT,traits,Allocator>& str);
basic_string(basic_string<charT,traits,Allocator>&& str) noexcept;

[…]

-3- Throws: The second form throws nothing if the allocator's move constructor throws nothing.

How can it ever throw anything if it is marked noexcept?

History
Date User Action Args
2014-02-20 13:20:35adminsetstatus: wp -> open
2012-02-12 18:36:43adminsetstatus: voting -> wp
2012-02-09 04:07:48adminsetstatus: ready -> voting
2011-08-16 23:35:18adminsetstatus: new -> ready
2011-08-16 23:35:18adminsetmessages: + msg5714
2011-07-11 20:04:43adminsetmessages: + msg5692
2011-07-11 20:04:43adminsetmessages: + msg5691
2011-07-01 00:00:00admincreate