Issue2235

Title 2235. Undefined behavior without proper requirements on basic_string constructors
Status open Section [string.cons]
Submitter Juan Soulie

Created on 2013-01-17.00:00:00 by admin, last changed by admin.

Messages
msg6647 (view) Date: 2013-09-29.10:16:57

Proposed resolution:

This wording is relative to N3485.

  1. Change [string.cons]/6 as indicated:

    basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
    

    -6- Requires: s shall not be a null pointer and n < npospoints to an array of at least n elements of charT.

  2. Change [string.cons]/8 as indicated:

    basic_string(const charT* s, const Allocator& a = Allocator());
    

    -8- Requires: s shall not be a null pointerpoints to an array of at least traits::length(s) + 1 elements of charT.

msg6456 (view) Date: 2013-09-15.00:00:00

[ 2013-09-29, Bristol ]

Apply to the Working Paper

msg6437 (view) Date: 2013-04-15.00:00:00

[ 2013-04-18, Bristol ]

Move to Ready

msg6376 (view) Date: 2013-03-15.00:00:00

[ 2013-03-15 Issues Teleconference ]

Moved to Review.

The resolution could be worded more cleanly, and there is some concern about redundancy between Requirements and Effects clauses. Consensus that we do want to say something like this for the Requirements though.

msg6375 (view) Date: 2013-01-17.00:00:00

In [string.cons], I believe tighter requirements should be imposed on basic_string's constructors taking an s argument (or, a behavior should be provided for the undefined cases). These requirements are properly stated in the other members functions taking s arguments (append, assign, insert,...).

basic_string(const charT* s, size_type n, const Allocator& a = Allocator());

Relative to N3485, [string.cons]/6 says "Requires: s shall not be a null pointer and n < npos", where it should say: "Requires: s points to an array of at least n elements of charT"

basic_string(const charT* s, const Allocator& a = Allocator());

[string.cons]/8 says "Requires: s shall not be a null pointer.", where it should say: "Requires: s points to an array of at least traits::length(s) + 1 elements of charT"

Daniel:

I think that [res.on.arguments] p1 b2 basically requires this already, but the wording is indeed worth improving it.

History
Date User Action Args
2014-02-20 13:20:35adminsetstatus: wp -> open
2013-09-29 10:16:57adminsetstatus: voting -> wp
2013-09-29 10:16:57adminsetmessages: + msg6647
2013-09-23 13:24:31adminsetstatus: ready -> voting
2013-04-18 22:58:13adminsetstatus: review -> ready
2013-04-18 22:58:13adminsetmessages: + msg6456
2013-03-18 14:33:00adminsetmessages: + msg6437
2013-03-18 13:02:36adminsetstatus: new -> review
2013-03-12 20:31:03adminsetmessages: + msg6376
2013-01-17 00:00:00admincreate