Doc. no. N3181=10-0171
Date: 2010-11-29
Project: Programming Language C++
Reply to: Alisdair Meredith <lwgchair@gmail.com>

C++ Standard Library Active Issues List (Revision R73)

Reference ISO/IEC IS 14882:2003(E)

Also see:

The purpose of this document is to record the status of issues which have come before the Library Working Group (LWG) of the INCITS PL22.16 and ISO WG21 C++ Standards Committee. Issues represent potential defects in the ISO/IEC IS 14882:2003(E) document.

This document contains only library issues which are actively being considered by the Library Working Group, i.e., issues which have a status of New, Open, Ready, or Review. See Library Defect Reports List for issues considered defects and Library Closed Issues List for issues considered closed.

The issues in these lists are not necessarily formal ISO Defect Reports (DR's). While some issues will eventually be elevated to official Defect Report status, other issues will be disposed of in other ways. See Issue Status.

Prior to Revision 14, library issues lists existed in two slightly different versions; a Committee Version and a Public Version. Beginning with Revision 14 the two versions were combined into a single version.

This document includes [bracketed italicized notes] as a reminder to the LWG of current progress on issues. Such notes are strictly unofficial and should be read with caution as they may be incomplete or incorrect. Be aware that LWG support for a particular resolution can quickly change if new viewpoints or killer examples are presented in subsequent discussions.

For the most current official version of this document see http://www.open-std.org/jtc1/sc22/wg21/. Requests for further information about this document should include the document number above, reference ISO/IEC 14882:2003(E), and be submitted to Information Technology Industry Council (ITI), 1250 Eye Street NW, Washington, DC 20005.

Public information as to how to obtain a copy of the C++ Standard, join the standards committee, submit an issue, or comment on an issue can be found in the comp.std.c++ FAQ.

How to submit an issue

  1. Mail your issue to the author of this list.
  2. Specify a short descriptive title. If you fail to do so, the subject line of your mail will be used as the issue title.
  3. If the "From" on your email is not the name you wish to appear as issue submitter, then specify issue submitter.
  4. Provide a brief discussion of the problem you wish to correct. Refer to the latest working draft or standard using [section.tag] and paragraph numbers where appropriate.
  5. Provide proposed wording. This should indicate exactly how you want the standard to be changed. General solution statements belong in the discussion area. This area contains very clear and specific directions on how to modify the current draft. If you are not sure how to word a solution, you may omit this part. But your chances of a successful issue greatly increase if you attempt wording.
  6. It is not necessary for you to use html markup. However, if you want to, you can <ins>insert text like this</ins> and <del>delete text like this</del>. The only strict requirement is to communicate clearly to the list maintainer exactly how you want your issue to look.
  7. It is not necessary for you to specify other html font/formatting mark-up, but if you do the list maintainer will attempt to respect your formatting wishes (as described by html markup, or other common idioms).
  8. It is not necessary for you to specify open date or last modified date (the date of your mail will be used).
  9. It is not necessary for you to cross reference other issues, but you can if you like. You do not need to form the hyperlinks when you do, the list maintainer will take care of that.
  10. One issue per email is best.
  11. Between the time you submit the issue, and the next mailing deadline (date at the top of the Revision History), you own this issue. You control the content, the stuff that is right, the stuff that is wrong, the format, the misspellings, etc. You can even make the issue disappear if you want. Just let the list maintainer know how you want it to look, and he will try his best to accommodate you. After the issue appears in an official mailing, you no longer enjoy exclusive ownership of it.

Revision History

Issue Status

New - The issue has not yet been reviewed by the LWG. Any Proposed Resolution is purely a suggestion from the issue submitter, and should not be construed as the view of LWG.

Open - The LWG has discussed the issue but is not yet ready to move the issue forward. There are several possible reasons for open status:

A Proposed Resolution for an open issue is still not be construed as the view of LWG. Comments on the current state of discussions are often given at the end of open issues in an italic font. Such comments are for information only and should not be given undue importance.

Deferred - The LWG has discussed the issue, is not yet ready to move the issue forward, but neither does it deem the issue significant enough to delay publishing a standard or Technical Report. A typical deferred issue would be seeking to clarify wording that might be technically correct, but easily mis-read.

A Proposed Resolution for a deferred issue is still not be construed as the view of LWG. Comments on the current state of discussions are often given at the end of open issues in an italic font. Such comments are for information only and should not be given undue importance.

Dup - The LWG has reached consensus that the issue is a duplicate of another issue, and will not be further dealt with. A Rationale identifies the duplicated issue's issue number.

NAD - The LWG has reached consensus that the issue is not a defect in the Standard.

NAD Editorial - The LWG has reached consensus that the issue can either be handled editorially, or is handled by a paper (usually linked to in the rationale).

NAD Concepts - The LWG has reached consensus that the issue is NAD for now, but represents a real issue when the library is done with language-supported concepts.

NAD Future - In addition to the regular status, the LWG believes that this issue should be revisited at the next revision of the standard.

Review - Exact wording of a Proposed Resolution is now available for review on an issue for which the LWG previously reached informal consensus.

Ready - The LWG has reached consensus that the issue is a defect in the Standard, the Proposed Resolution is correct, and the issue is ready to forward to the full committee for further action as a Defect Report (DR).

Resolved - The LWG has reached consensus that the issue is a defect in the Standard, but the resolution adopted to resolve the issue came via some other mechanism than this issue in the list - typically by applying a formal paper, occasionally as a side effect of consolidating several interacting issue resolutions into a single issue.

DR - (Defect Report) - The full WG21/PL22.16 committee has voted to forward the issue to the Project Editor to be processed as a Potential Defect Report. The Project Editor reviews the issue, and then forwards it to the WG21 Convenor, who returns it to the full committee for final disposition. This issues list accords the status of DR to all these Defect Reports regardless of where they are in that process.

TC1 - (Technical Corrigenda 1) - The full WG21/PL22.16 committee has voted to accept the Defect Report's Proposed Resolution as a Technical Corrigenda. Action on this issue is thus complete and no further action is possible under ISO rules.

CD1 - (Committee Draft 2008) - The full WG21/PL22.16 committee has voted to accept the Defect Report's Proposed Resolution into the Fall 2008 Committee Draft.

TRDec - (Decimal TR defect) - The LWG has voted to accept the Defect Report's Proposed Resolution into the Decimal TR. Action on this issue is thus complete and no further action is expected.

WP - (Working Paper) - The proposed resolution has not been accepted as a Technical Corrigendum, but the full WG21/PL22.16 committee has voted to apply the Defect Report's Proposed Resolution to the working paper.

Tentatively - This is a status qualifier. The issue has been reviewed online, or at an unofficial meeting, but not in an official meeting, and some support has been formed for the qualified status. Tentatively qualified issues may be moved to the unqualified status and forwarded to full committee (if Ready) within the same meeting. Unlike Ready issues, Tentatively Ready issues will be reviewed in subcommittee prior to forwarding to full committee. When a status is qualified with Tentatively, the issue is still considered active.

Pending - This is a status qualifier. When prepended to a status this indicates the issue has been processed by the committee, and a decision has been made to move the issue to the associated unqualified status. However for logistical reasons the indicated outcome of the issue has not yet appeared in the latest working paper.

Issues are always given the status of New when they first appear on the issues list. They may progress to Open or Review while the LWG is actively working on them. When the LWG has reached consensus on the disposition of an issue, the status will then change to Dup, NAD, or Ready as appropriate. Once the full J16 committee votes to forward Ready issues to the Project Editor, they are given the status of Defect Report ( DR). These in turn may become the basis for Technical Corrigenda (TC), or are closed without action other than a Record of Response (RR ). The intent of this LWG process is that only issues which are truly defects in the Standard move to the formal ISO DR status.

Active Issues


964. Various threading bugs #14

Section: 30.5.2 [thread.condition.condvarany] Status: Open Submitter: Pete Becker Opened: 2009-01-07 Last modified: 2010-10-29

View all other issues in [thread.condition.condvarany].

View all issues with Open status.

Discussion:

The requirements for the constructor for condition_variable has several error conditions, but the requirements for the constructor for condition_variable_any has none. Is this difference intentional?

[ Summit: ]

Move to open, pass to Howard. If this is intentional, a note may be helpful. If the error conditions are to be copied from condition_variable, this depends on LWG 965.

[ Post Summit Howard adds: ]

The original intention (N2447) was to let the OS return whatever errors it was going to return, and for those to be translated into exceptions, for both condition_variable and condition_variable_any. I have not received any complaints about specific error conditions from vendors on non-POSIX platforms, but such complaints would not surprise me if they surfaced.

[ 2009-10 Santa Cruz: ]

Leave open. Benjamin to provide wording.

[ 2010 Pittsburgh: ]

We don't have throw clauses for condition variables.

This issue may be dependent on LWG 1268.

Leave open. Detlef will coordinate with Benjamin.

Consider merging LWG 964, 966, and 1268 into a single paper.

Proposed resolution:


966. Various threading bugs #16

Section: 30.5.1 [thread.condition.condvar] Status: Open Submitter: Pete Becker Opened: 2009-01-07 Last modified: 2010-10-29

View all other issues in [thread.condition.condvar].

View all issues with Open status.

Discussion:

30.5.1 [thread.condition.condvar]: condition_variable::wait and condition_variable::wait_until both have a postcondition that lock is locked by the calling thread, and a throws clause that requires throwing an exception if this postcondition cannot be achieved. How can the implementation detect that this lock can never be obtained?

[ Summit: ]

Move to open. Requires wording. Agreed this is an issue, and the specification should not require detecting deadlocks.

[ 2009-08-01 Howard provides wording. ]

The proposed wording is inspired by the POSIX spec which says:

[EINVAL]
The value specified by cond or mutex is invalid.
[EPERM]
The mutex was not owned by the current thread at the time of the call.

I do not believe [EINVAL] is possible without memory corruption (which we don't specify). [EPERM] is possible if this thread doesn't own the mutex, which is listed as a precondition. "May" is used instead of "Shall" because not all OS's are POSIX.

[ 2009-10 Santa Cruz: ]

Leave open, Detlef to provide improved wording.

[ 2009-10-23 Detlef Provided wording. ]

Detlef's wording put in Proposed resolution. Original wording here:

Change 30.5.1 [thread.condition.condvar] p12, p19 and 30.5.2 [thread.condition.condvarany] p10, p16:

Throws: May throw std::system_error if a precondition is not met. when the effects or postcondition cannot be achieved.

[ 2009-10 Santa Cruz: ]

Leave open, Detlef to provide improved wording.

[ 2009-11-18 Anthony adds: ]

condition_variable::wait takes a unique_lock<mutex>. We know whether or not a unique_lock owns a lock, through use of its owns_lock() member.

I would like to propose the following resolution:

Modify the first sentence of 30.5.1 [thread.condition.condvar] p9:

void wait(unique_lock<mutex>& lock);
9 Precondition: lock is locked by the calling thread lock.owns_lock() is true, and either

...

Replace 30.5.1 [thread.condition.condvar] p11-13 with:

void wait(unique_lock<mutex>& lock);

...

11 Postcondition: lock is locked by the calling thread lock.owns_lock() is true.

12 Throws: std::system_error when the effects or postcondition cannot be achieved if the implementation detects that the preconditions are not met or the effects cannot be achieved. Any exception thrown by lock.lock() or lock.unlock().

13 Error Conditions: The error conditions are implementation defined.

  • equivalent error condition from lock.lock() or lock.unlock().

[ 2010 Pittsburgh: ]

There are heavy conflicts with adopted papers.

This issue is dependent on LWG 1268.

Leave open pending outstanding edits to the working draft. Detlef will provide wording.

Possibly related to 964.

Proposed resolution:

Replace 30.5.1 [thread.condition.condvar] p12, p19 and 30.5.2 [thread.condition.condvarany] p10, p16:

Throws: std::system_error when the effects or postcondition cannot be achieved.

Error conditions:

Throws: It is implementation-defined whether a std::system_error with implementation-defined error condition is thrown if the precondition is not met.


985. Allowing throwing move

Section: 23.2.1 [container.requirements.general] Status: Open Submitter: Rani Sharoni Opened: 2009-02-12 Last modified: 2010-10-29

View other active issues in [container.requirements.general].

View all other issues in [container.requirements.general].

View all issues with Open status.

Discussion:

Introduction

This proposal is meant to resolve potential regression of the N2800 draft, see next section, and to relax the requirements for containers of types with throwing move constructors.

The basic problem is that some containers operations, like push_back, have a strong exception safety guarantee (i.e. no side effects upon exception) that are not achievable when throwing move constructors are used since there is no way to guarantee revert after partial move. For such operations the implementation can at most provide the basic guarantee (i.e. valid but unpredictable) as it does with multi copying operations (e.g. range insert).

For example, vector<T>::push_back() (where T has a move constructor) might resize the vector and move the objects to the new underlying buffer. If move constructor throws it might not be possible to recover the throwing object or to move the old objects back to the original buffer.

The current draft is explicit by disallowing throwing move for some operations (e.g. vector<>::reserve) and not clear about other operations mentioned in 23.2.1 [container.requirements.general]/10 (e.g. single element insert): it guarantees strong exception safety without explicitly disallowing a throwing move constructor.

Regression

This section only refers to cases in which the contained object is by itself a standard container.

Move constructors of standard containers are allowed to throw and therefore existing operations are broken, compared with C++03, due to move optimization. (In fact existing implementations like Dinkumware are actually throwing).

For example, vector< list<int> >::reserve yields undefined behavior since list<int>'s move constructor is allowed to throw. On the other hand, the same operation has strong exception safety guarantee in C++03.

There are few options to solve this regression:

  1. Disallow throwing move and throwing default constructor
  2. Disallow throwing move but disallowing usage after move
  3. Special casing
  4. Disallow throwing move and making it optional

Option 1 is suggested by proposal N2815 but it might not be applicable for existing implementations for which containers default constructors are throwing.

Option 2 limits the usage significantly and it's error prone by allowing zombie objects that are nothing but destructible (e.g. no clear() is allowed after move). It also potentially complicates the implementation by introducing special state.

Option 3 is possible, for example, using default construction and swap instead of move for standard containers case. The implementation is also free to provide special hidden operation for non throwing move without forcing the user the cope with the limitation of option-2 when using the public move.

Option 4 impact the efficiency in all use cases due to rare throwing move.

The proposed wording will imply option 1 or 3 though option 2 is also achievable using more wording. I personally oppose to option 2 that has impact on usability.

Relaxation for user types

Disallowing throwing move constructors in general seems very restrictive since, for example, common implementation of move will be default construction + swap so move will throw if the default constructor will throw. This is currently the case with the Dinkumware implementation of node based containers (e.g. std::list) though this section doesn't refer to standard types.

For throwing move constructors it seem that the implementation should have no problems to provide the basic guarantee instead of the strong one. It's better to allow throwing move constructors with basic guarantee than to disallow it silently (compile and run), via undefined behavior.

There might still be cases in which the relaxation will break existing generic code that assumes the strong guarantee but it's broken either way given a throwing move constructor since this is not a preserving optimization.

[ Batavia (2009-05): ]

Bjarne comments (referring to his draft paper): "I believe that my suggestion simply solves that. Thus, we don't need a throwing move."

Move to Open and recommend it be deferred until after the next Committee Draft is issued.

[ 2009-10 Santa Cruz: ]

Should wait to get direction from Dave/Rani (N2983).

[ 2010-03-28 Daniel updated wording to sync with N3092. ]

The suggested change of 23.3.2.3 [deque.modifiers]/2 should be removed, because the current wording does say more general things:

2 Remarks: If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move assignment operator of T there are no effects. If an exception is thrown by the move constructor of a non-CopyConstructible T, the effects are unspecified.

The suggested change of 23.4.1.2 [vector.capacity]/2 should be removed, because the current wording does say more general things:

2 Effects: A directive that informs a vector of a planned change in size, so that it can manage the storage allocation accordingly. After reserve(), capacity() is greater or equal to the argument of reserve if reallocation happens; and equal to the previous value of capacity() otherwise. Reallocation happens at this point if and only if the current capacity is less than the argument of reserve(). If an exception is thrown other than by the move constructor of a non-CopyConstructible type, there are no effects.

Proposed resolution:

23.2.1 [container.requirements.general] paragraph 11 add footnote:

-11- Unless otherwise specified (see 23.1.4.1, 23.1.5.1, 23.2.2.3, and 23.2.6.4) all container types defined in this Clause meet the following additional requirements:

[Note: for compatibility with C++ 2003, when "no effect" is required, standard containers should not use the value_type's throwing move constructor when the contained object is by itself a standard container. -- end note]

23.2.5.1 [unord.req.except] change paragraph 2 to say:

-2- For unordered associative containers, if an exception is thrown by any operation other than the container's hash function from within an insert() function inserting a single element, the insert() function has no effect unless the exception is thrown by the contained object move constructor.

-4- For unordered associative containers, if an exception is thrown from within a rehash() function other than by the container's hash function or comparison function, the rehash() function has no effect unless the exception is thrown by the contained object move constructor.

23.3.2.3 [deque.modifiers] change paragraph 2 to say:

-2- Remarks: If an exception is thrown other than by the copy constructor, move constructor or assignment operator of T there are no effects. If an exception is thrown by push_back() or emplace_back() function, that function has no effects unless the exception is thrown by the move constructor of T.

23.4.1.2 [vector.capacity] paragraph 2 change to say:

-2- Effects: A directive that informs a vector of a planned change in size, so that it can manage the storage allocation accordingly. After reserve(), capacity() is greater or equal to the argument of reserve if reallocation happens; and equal to the previous value of capacity() otherwise. Reallocation happens at this point if and only if the current capacity is less than the argument of reserve(). If an exception is thrown, there are no effects unless the exception is thrown by the contained object move constructor.

23.4.1.2 [vector.capacity] paragraph 12 change to say:

-12- Requires: If value_type has a move constructor, that constructor shall not throw any exceptions. If an exception is thrown, there are no effects unless the exception is thrown by the contained object move constructor.

23.4.1.4 [vector.modifiers] change paragraph 1 to say:

-1- Requires: If value_type has a move constructor, that constructor shall not throw any exceptions. Remarks: If an exception is thrown by push_back() or emplace_back() function, that function has no effect unless the exception is thrown by the move constructor of T.

1169. num_get not fully compatible with strto*

Section: 22.4.2.1.2 [facet.num.get.virtuals] Status: Open Submitter: Cosmin Truta Opened: 2009-07-04 Last modified: 2010-10-23

View all other issues in [facet.num.get.virtuals].

View all issues with Open status.

Discussion:

As specified in the latest draft, N2914, num_get is still not fully compatible with the following C functions: strtoul, strtoull, strtof and strtod.

In C, when conversion of a string to an unsigned integer type falls outside the representable range, strtoul and strtoull return ULONG_MAX and ULLONG_MAX, respectively, regardless whether the input field represents a positive or a negative value. On the other hand, the result of num_get conversion of negative values to unsigned integer types is zero. This raises a compatibility issue.

Moreover, in C, when conversion of a string to a floating-point type falls outside the representable range, strtof, strtod and strtold return ±HUGE_VALF, ±HUGE_VAL and ±HUGE_VALL, respectively. On the other hand, the result of num_get conversion of such out-of-range floating-point values results in the most positive/negative representable value. Although many C library implementations do implement HUGE_VAL (etc.) as the highest representable (which is, usually, the infinity), this isn't required by the C standard. The C library specification makes no statement regarding the value of HUGE_VAL and friends, which potentially raises the same compatibility issue as in the above case of unsigned integers. In addition, neither C nor C++ define symbolic constants for the maximum representable floating-point values (they only do so only for the maximum representable finite floating-point values), which raises a usability issue (it would be hard for the programmer to check the result of num_get against overflow).

As such, we propose to adjust the specification of num_get to closely follow the behavior of all of its underlying C functions.

[ 2010 Rapperswil: ]

Some concern that this is changing the specification for an existing C++03 function, but it was pointed out that this was underspecified as resolved by issue 23. This is clean-up for that issue in turn. Some concern that we are trying to solve the same problem in both clause 22 and 27. Bill: There's a change here as to whether val is stored to in an error case. Pablo: Don't think this changes whether val is stored to or not, but changes the value that is stored. Bill: Remembers having skirmishes with customers and testers as to whether val is stored to, and the resolution was not to store in error cases. Howard: Believes since C++03 we made a change to always store in overflow. Everyone took some time to review the issue. Pablo: C++98 definitely did not store any value during an error condition. Dietmar: Depends on the question of what is considered an error, and whether overflow is an error or not, which was the crux of LWG 23. Pablo: Yes, but given the "zero, if the conversion function fails to convert the entire field", we are requiring every error condition to store. Bill: When did this happen? Alisdair: One of the last two or three meetings. Dietmar: To store a value in case of failure is a very bad idea. Move to Open, needs more study.

Proposed resolution:

Change 22.4.2.1.2 [facet.num.get.virtuals] as follows:

Stage 3: The sequence of chars accumulated in stage 2 (the field) is converted to a numeric value by the rules of one of the functions declared in the header <cstdlib>:

The numeric value to be stored can be one of:

The resultant numeric value is stored in val. If the conversion function fails to convert the entire field, or if the field represents a value outside the range of representable values, ios_base::failbit is assigned to err.


1175. unordered complexity

Section: 23.2.5 [unord.req] Status: Open Submitter: Pablo Halpern Opened: 2009-07-17 Last modified: 2010-10-23

View other active issues in [unord.req].

View all other issues in [unord.req].

View all issues with Open status.

Discussion:

When I look at the unordered_* constructors, I think the complexity is poorly described and does not follow the style of the rest of the standard.

The complexity for the default constructor is specified as constant. Actually, it is proportional to n, but there are no invocations of value_type constructors or other value_type operations.

For the iterator-based constructor the complexity should be:

Complexity: exactly n calls to construct value_type from InputIterator::value_type (where n = distance(f,l)). The number of calls to key_equal::operator() is proportional to n in the average case and n*n in the worst case.

[ 2010 Rapperswil: ]

Concern that the current wording may require O(1) where that cannot be delivered. We need to look at both the clause 23 requirements tables and the constructor description of each unodered container to be sure. Howard suggests NAD Editorial as we updated the container requirement tables since this issue was written. Daniel offers to look deeper, and hopefully produce wording addressing any outstanding concerns at the next meeting. Move to Open.

Proposed resolution:


1213. Meaning of valid and singular iterator underspecified

Section: 24.2 [iterator.requirements] Status: Deferred Submitter: Daniel Krügler Opened: 2009-09-19 Last modified: 2010-11-14

View all other issues in [iterator.requirements].

View all issues with Deferred status.

Discussion:

The terms valid iterator and singular aren't properly defined. The fuzziness of those terms became even worse after the resolution of 208 (including further updates by 278). In 24.2 [iterator.requirements] as of N2723 the standard says now:

5 - These values are called past-the-end values. Values of an iterator i for which the expression *i is defined are called dereferenceable. The library never assumes that past-the-end values are dereferenceable. Iterators can also have singular values that are not associated with any container. [...] Results of most expressions are undefined for singular values; the only exceptions are destroying an iterator that holds a singular value and the assignment of a non-singular value to an iterator that holds a singular value. [...] Dereferenceable values are always non-singular.

10 - An invalid iterator is an iterator that may be singular.

First, issue 208 intentionally removed the earlier constraint that past-the-end values are always non-singular. The reason for this was to support null pointers as past-the-end iterators of e.g. empty sequences. But there seem to exist different views on what a singular (iterator) value is. E.g. according to the SGI definition a null pointer is not a singular value:

Dereferenceable iterators are always nonsingular, but the converse is not true. For example, a null pointer is nonsingular (there are well defined operations involving null pointers) even thought it is not dereferenceable.

and proceeds:

An iterator is valid if it is dereferenceable or past-the-end.

Even if the standard prefers a different meaning of singular here, the change was incomplete, because by restricting feasible expressions of singular iterators to destruction and assignment isn't sufficient for a past-the-end iterator: Of-course it must still be equality-comparable and in general be a readable value.

Second, the standard doesn't clearly say whether a past-the-end value is a valid iterator or not. E.g. 20.9.8 [specialized.algorithms]/1 says:

In all of the following algorithms, the formal template parameter ForwardIterator is required to satisfy the requirements of a forward iterator (24.1.3) [..], and is required to have the property that no exceptions are thrown from [..], or dereference of valid iterators.

The standard should make better clear what "singular pointer" and "valid iterator" means. The fact that the meaning of a valid value has a core language meaning doesn't imply that for an iterator concept the term "valid iterator" has the same meaning.

Let me add a final example: In X [allocator.concepts.members] of N2914 we find:

pointer X::allocate(size_type n);
11 Returns: a pointer to the allocated memory. [Note: if n == 0, the return value is unspecified. —end note]

[..]

void X::deallocate(pointer p, size_type n);
Preconditions: p shall be a non-singular pointer value obtained from a call to allocate() on this allocator or one that compares equal to it.

If singular pointer value would include null pointers this make the preconditions unclear if the pointer value is a result of allocate(0): Since the return value is unspecified, it could be a null pointer. Does that mean that programmers need to check the pointer value for a null value before calling deallocate?

[ 2010-11-09 Daniel comments: ]

A later paper is in preparation.

[ 2010 Batavia: ]

Doesn't need to be resolved for Ox

Proposed resolution:

Consider to await the paper.

1214. Insufficient/inconsistent key immutability requirements for associative containers

Section: 23.2.4 [associative.reqmts] Status: Deferred Submitter: Daniel Krügler Opened: 2009-09-20 Last modified: 2010-11-14

View other active issues in [associative.reqmts].

View all other issues in [associative.reqmts].

View all issues with Deferred status.

Discussion:

Scott Meyers' mentions on a recent posting on c.s.c++ some arguments that point to an incomplete resolution of 103 and to an inconsistency of requirements on keys in ordered and unordered associative containers:

1) 103 introduced the term immutable without defining it in a unique manner in 23.2.4 [associative.reqmts]/5:

[..] Keys in an associative container are immutable.

According to conventional dictionaries immutable is an unconditional way of saying that something cannot be changed. So without any further explicit allowance a user always runs into undefined behavior if (s)he attempts to modify such a key. IMO this was not the intend of the committee to resolve 103 in that way because the comments suggest an interpretation that should give any user the freedom to modify the key in an explicit way provided it would not affect the sort order in that container.

2) Another observation was that surprisingly no similar 'safety guards' exists against unintentional key changes for the unordered associative containers, specifically there is no such requirement as in 23.2.4 [associative.reqmts]/6 that "both iterator and const_iterator are constant iterators". But the need for such protection against unintentional changes as well as the constraints in which manner any explicit changes may be performed are both missing and necessary, because such changes could potentially change the equivalence of keys that is measured by the hasher and key_equal.

I suggest to fix the unconditional wording involved with "immutable keys" by at least adding a hint for the reader that users may perform such changes in an explicit manner and to perform similar wording changes as 103 did for the ordered associative containers also for the unordered containers.

[ 2010-03-27 Daniel provides wording. ]

This update attempts to provide normative wording that harmonizes the key and function object constraints of associative and unordered containers.

[ 2010 Batavia: ]

We're uncomfortable with the first agenda item, and we can live with the second agenda item being applied before or after Madrid.

Proposed resolution:

  1. Change 23.2.4 [associative.reqmts]/2 as indicated: [This ensures that associative containers make better clear what this "arbitrary" type is, as the unordered containers do in 23.2.5 [unord.req]/3]

    2 Each associative container is parameterized on Key and an ordering relation Compare that induces a strict weak ordering (25.4) on elements of Key. In addition, map and multimap associate an arbitrary mapped typetype T with the Key. The object of type Compare is called the comparison object of a container.
  2. Change 23.2.4 [associative.reqmts]/5 as indicated: [This removes the too strong requirement that keys must not be changed at all and brings this line in sync with 23.2.5 [unord.req]/7. We take care about the real constraints by the remaining suggested changes. The rationale provided by LWG 103 didn't really argue why that addition is necessary, and I believe the remaining additions make it clear that any user changes have strong restrictions]:

    5 For set and multiset the value type is the same as the key type. For map and multimap it is equal to pair<const Key, T>. Keys in an associative container are immutable.
  3. Change 23.2.5 [unord.req]/3+4 as indicated: [The current sentence of p.4 has doesn't say something really new and this whole subclause misses to define the concepts of the container-specific hasher object and predicate object. We introduce the term key equality predicate which is already used in the requirements table. This change does not really correct part of this issue, but is recommended to better clarify the nomenclature and the difference between the function objects and the function object types, which is important, because both can potentially be stateful.]

    3 Each unordered associative container is parameterized by Key, by a function object type Hash that meets the Hash requirements (20.2.4) and acts as a hash function for argument values of type Key, and by a binary predicate Pred that induces an equivalence relation on values of type Key. Additionally, unordered_map and unordered_multimap associate an arbitrary mapped type T with the Key.

    4 The container's object of type Hash - denoted by hash - is called the hash function of the container. The container's object of type Pred - denoted by pred - is called the key equality predicate of the container.A hash function is a function object that takes a single argument of type Key and returns a value of type std::size_t.

  4. Change 23.2.5 [unord.req]/5 as indicated: [This adds a similar safe-guard as the last sentence of 23.2.4 [associative.reqmts]/3]

    5 Two values k1 and k2 of type Key are considered equivalent if the container's key equality predicatekey_equal function object returns true when passed those values. If k1 and k2 are equivalent, the container's hash function shall return the same value for both. [Note: thus, when an unordered associative container is instantiated with a non-default Pred parameter it usually needs a non-default Hash parameter as well. — end note] For any two keys k1 and k2 in the same container, calling pred(k1, k2) shall always return the same value. For any key k in a container, calling hash(k) shall always return the same value.
  5. After 23.2.5 [unord.req]/7 add the following new paragraph: [This ensures the same level of compile-time protection that we already require for associative containers. It is necessary for similar reasons, because any change in the stored key which would change it's equality relation to others or would change it's hash value such that it would no longer fall in the same bucket, would break the container invariants]

    7 For unordered_set and unordered_multiset the value type is the same as the key type. For unordered_map and unordered_multimap it is std::pair<const Key, T>.

    For unordered containers where the value type is the same as the key type, both iterator and const_iterator are constant iterators. It is unspecified whether or not iterator and const_iterator are the same type. [Note: iterator and const_iterator have identical semantics in this case, and iterator is convertible to const_iterator. Users can avoid violating the One Definition Rule by always using const_iterator in their function parameter lists. — end note]


1215. list::merge with unequal allocators

Section: 23.3.4.4 [list.ops] Status: Tentatively Ready Submitter: Pablo Halpern Opened: 2009-09-24 Last modified: 2010-11-13

View all other issues in [list.ops].

View all issues with Tentatively Ready status.

Discussion:

In Bellevue (I think), we passed N2525, which, among other things, specifies that the behavior of list::splice is undefined if the allocators of the two lists being spliced do not compare equal. The same rationale should apply to list::merge. The intent of list::merge (AFAIK) is to move nodes from one sorted list into another sorted list without copying the elements. This is possible only if the allocators compare equal.

Proposed resolution:

Relative to the August 2009 WP, N2857, change 23.3.4.4 [list.ops], paragraphs 22-25 as follows:

void merge(list&& x);
template <class Compare> void merge(list&& x, Compare comp);

Requires: both the list and the argument list shall be sorted according to operator< or comp.

Effects: If (&x == this) does nothing; otherwise, merges the two sorted ranges [begin(), end()) and [x.begin(), x.end()). The result is a range in which the elements will be sorted in non-decreasing order according to the ordering defined by comp; that is, for every iterator i, in the range other than the first, the condition comp(*i, *(i - 1)) will be false.

Remarks: Stable. If (&x != this) the range [x.begin(), x.end()) is empty after the merge. No elements are copied by this operation. The behavior is undefined if this->get_allocator() != x.get_allocator().

Complexity: At most size() + x.size() - 1 applications of comp if (&x != this); otherwise, no applications of comp are performed. If an exception is thrown other than by a comparison there are no effects.


1252. wbuffer_convert::state_type inconsistency

Section: 22.3.3.2.3 [conversions.buffer] Status: Open Submitter: Bo Persson Opened: 2009-10-21 Last modified: 2010-11-13

View all issues with Open status.

Discussion:

The synopisis for wbuffer_convert 22.3.3.2.3 [conversions.buffer]/2 contains

typedef typename Tr::state_type   state_type; 

making state_type a synonym for (possibly) some char_traits<x>::state_type.

However, in paragraph 9 of the same section, we have

typedef typename Codecvt::state_type state_type;
The type shall be a synonym for Codecvt::state_type.

From what I can see, it might be hard to implement wbuffer_convert if the types were not both std::mbstate_t, but I cannot find a requirement that they must be the same type.

[ Batavia 2010: ]

Howard to draft wording, move to Review. Run it by Bill. Need to move this in Madrid.

Proposed resolution:


1253. invalidation of iterators and emplace vs. insert inconsistence in assoc. containers

Section: 23.2.4 [associative.reqmts] Status: Tentatively Ready Submitter: Boris Dušek Opened: 2009-10-24 Last modified: 2010-11-13

View other active issues in [associative.reqmts].

View all other issues in [associative.reqmts].

View all issues with Tentatively Ready status.

Discussion:

In the latest published draft N2960, section 23.2.4 [associative.reqmts], paragraph 8, it is specifies that that insert does not invalidate any iterators. As per 23.2.1 [container.requirements.general], paragraph 12, this holds true not only for insert, but emplace as well. This gives the insert member a special treatment w.r.t. emplace member in 23.2.4 [associative.reqmts], par. 8, since both modify the container. For the sake of consistency, in 23.2.4 [associative.reqmts], par. 8: either reference to insert should be removed (i.e. count on 23.2.1 [container.requirements.general], par. 12), or reference to emplace be added (i.e. mention all members of assoc. containers that modify it).

[ 2009-11-18 Chris provided wording. ]

This suggested wording covers both the issue discussed, and a number of other identical issues (namely insert being discussed without emplace). I'm happy to go back and split and introduce a new issue if appropriate, but I think the changes are fairly mechanical and obvious.

[ 2010-01-23 Daniel Krügler and J. Daniel García updated wording to make the use of hint consistent with insert. ]

Proposed resolution:

Modify bullet 1 of 23.2.1 [container.requirements.general], p10:

10 Unless otherwise specified (see 23.2.4.1, 23.2.5.1, 23.3.2.3, and 23.3.6.4) all container types defined in this Clause meet the following additional requirements:

Modify 23.2.4 [associative.reqmts], p4:

4 An associative container supports unique keys if it may contain at most one element for each key. Otherwise, it supports equivalent keys. The set and map classes support unique keys; the multiset and multimap classes support equivalent keys. For multiset and multimap, insert, emplace, and erase preserve the relative ordering of equivalent elements.

Modify Table 96 — Associative container requirements in 23.2.4 [associative.reqmts]:

Table 96 — Associative container requirements (in addition to container)
Expression Return type Assertion/note
pre-/post-condition
Complexity
...
a_eq.emplace(args) iterator inserts a T object t constructed with std::forward<Args>(args)... and returns the iterator pointing to the newly inserted element. If a range containing elements equivalent to t exists in a_eq, t is inserted at the end of that range. logarithmic
a.emplace_hint(p, args) iterator equivalent to a.emplace(std::forward<Args>(args)...). Return value is an iterator pointing to the element with the key equivalent to the newly inserted element. The const_iterator p is a hint pointing to where the search should start. The element is inserted as close as possible to the position just prior to p. Implementations are permitted to ignore the hint. logarithmic in general, but amortized constant if the element is inserted right after before p
...

Modify 23.2.4 [associative.reqmts], p8:

8 The insert and emplace members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements.

Modify 23.2.4.1 [associative.reqmts.except], p2:

2 For associative containers, if an exception is thrown by any operation from within an insert() or emplace() function inserting a single element, the insert() function insertion has no effect.

Modify 23.2.5 [unord.req], p6, p12 and p13:

6 An unordered associative container supports unique keys if it may contain at most one element for each key. Otherwise, it supports equivalent keys. unordered_set and unordered_map support unique keys. unordered_multiset and unordered_multimap support equivalent keys. In containers that support equivalent keys, elements with equivalent keys are adjacent to each other. For unordered_multiset and unordered_multimap, insert, emplace, and erase preserve the relative ordering of equivalent elements.

12 The insert and emplace members shall not affect the validity of references to container elements, but may invalidate all iterators to the container. The erase members shall invalidate only iterators and references to the erased elements.

13 The insert and emplace members shall not affect the validity of iterators if (N+n) < z * B, where N is the number of elements in the container prior to the insert operation, n is the number of elements inserted, B is the container's bucket count, and z is the container's maximum load factor.

Modify 23.2.5.1 [unord.req.except], p2:

2 For unordered associative containers, if an exception is thrown by any operation other than the container's hash function from within an insert() or emplace() function inserting a single element, the insert() insertion function has no effect.

1279. forbid [u|bi]nary_function specialization

Section: X [base] Status: Ready Submitter: Alberto Ganesh Barbati Opened: 2009-11-30 Last modified: 2010-11-13

View all other issues in [base].

View all issues with Ready status.

Discussion:

A program should not be allowed to add specialization of class templates unary_function and binary_function, in force of 17.6.3.2.1 [namespace.std]/1. If a program were allowed to specialize these templates, the library could no longer rely on them to provide the intended typedefs or there might be other undesired interactions.

[ 2010-03-27 Daniel adds: ]

Accepting issue 1290 would resolve this issue as NAD editorial.

[ 2010-10-24 Daniel adds: ]

Accepting n3145 would resolve this issue as NAD editorial.

[ 2010 Batavia: Solved by N3198 ]

Previous proposed resolution:

Change paragraph X [base]/1 as follows:

1 The following classes class templates are provided to simplify the typedefs of the argument and result types:. A program shall not declare specializations of these templates.

Proposed resolution:

Addressed by paper D3198.

1297. unique_ptr's relational operator functions should induce a total order

Section: 20.9.9.4 [unique.ptr.special] Status: Open Submitter: Daniel Krügler Opened: 2009-12-23 Last modified: 2010-11-13

View all issues with Open status.

Discussion:

The comparison functions of unique_ptr currently directly delegate to the underlying comparison functions of unique_ptr<T, D>::pointer. This is disadvantageous, because this would not guarantee to induce a total ordering for native pointers and it is hard to define a total order for mixed types anyway.

The currently suggested resolution for shared_ptr comparison as of 1262 uses a normalization strategy: They perform the comparison on the composite pointer type (5.9 [expr.rel]). This is not exactly possible for unique_ptr in the presence of user-defined pointer-like types but the existing definition of std::duration comparison as of 20.11.3.6 [time.duration.comparisons] via common_type of both argument types demonstrates a solution of this problem. The approach can be seen as the general way to define a composite pointer type and this is the approach which is used for here suggested wording change.

For consistency reasons I would have preferred the same normalization strategy for == and !=, but Howard convinced me not to do so (now).

[ 2010-11-03 Daniel comments and adjustes the currently proposed wording changes: ]

Issue 1401 is remotely related. Bullet A of its proposed resolution provides an alternative solution for issue discussed here and addresses NB comment GB-99. Additionally I updated the below suggested wording in regard to the following: It is an unncessary requirement that the below defined effective composite pointer-like type CT satisfies the LessThanComparable requirements. All what is needed is, that the function object type less<CT> induces a strict weak ordering on the pointer values.

Proposed resolution:

Change 20.9.9.4 [unique.ptr.special]/4-7 as indicated: [The implicit requirements and remarks imposed on the last three operators are the same as for the first one due to the normative "equivalent to" usage within a Requires element, see 17.5.1.4 [structure.specifications]/4. The effects of this change are that all real pointers wrapped in a unique_ptr will order like shared_ptr does.]

template <class T1, class D1, class T2, class D2>
  bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);

? Requires: Let CT be common_type<unique_ptr<T1, D1>::pointer, unique_ptr<T2, D2>::pointer>::type. Then the specialization less<CT> shall be a function object type ([function.objects]) that induces a strict weak ordering ([alg.sorting]) on the pointer values.

4 Returns: less<CT>()(x.get(), y.get())x.get() < y.get().

? Remarks: If unique_ptr<T1, D1>::pointer is not implicitly convertible to CT or unique_ptr<T2, D2>::pointer is not implicitly convertible to CT, the program is ill-formed.

template <class T1, class D1, class T2, class D2>
  bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
5 Effects: Equivalent to return !(y < x) Returns: x.get() <= y.get().
template <class T1, class D1, class T2, class D2>
  bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
6 Effects: Equivalent to return (y < x) Returns: x.get() > y.get().
template <class T1, class D1, class T2, class D2>
  bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
7 Effects: Equivalent to return !(x < y) Returns: x.get() >= y.get().

1310. forward_list splice_after from lvalues

Section: 23.3.3.5 [forwardlist.ops] Status: Tentatively Ready Submitter: Howard Hinnant Opened: 2010-02-05 Last modified: 2010-11-13

View all other issues in [forwardlist.ops].

View all issues with Tentatively Ready status.

Discussion:

We've moved 1133 to Tentatively Ready and I'm fine with that.

1133 adds lvalue-references to the splice signatures for list. So now list can splice from lvalue and rvalue lists (which was the intent of the original move papers btw). During the discussion of this issue it was mentioned that if we want to give the same treatment to forward_list, that should be a separate issue.

This is that separate issue.

Consider the following case where you want to splice elements from one place in a forward_list to another. Currently this must be coded like so:

fl.splice_after(to_here, std::move(fl), from1, from2);

This looks pretty shocking to me. I would expect to be able to code instead:

fl.splice_after(to_here, fl, from1, from2);

but we currently don't allow it.

When I say move(fl), I consider that as saying that I don't care about the value of fl any more (until I assign it a new value). But in the above example, this simply isn't true. I do care about the value of fl after the move, and I'm not assigning it a new value. I'm merely permuting its current value.

I propose adding forward_list& overloads to the 3 splice_after members. For consistency's sake (principal of least surprise) I'm also proposing to overload merge this way as well.

Proposed resolution:

Add to the synopsis of 23.3.3 [forwardlist]:

template <class T, class Allocator = allocator<T> >
class forward_list {
public:
  ...
  void splice_after(const_iterator p, forward_list& x);
  void splice_after(const_iterator p, forward_list&& x);
  void splice_after(const_iterator p, forward_list& x, const_iterator i);
  void splice_after(const_iterator p, forward_list&& x, const_iterator i);
  void splice_after(const_iterator p, forward_list& x,
                    const_iterator first, const_iterator last);
  void splice_after(const_iterator p, forward_list&& x,
                    const_iterator first, const_iterator last);
  ...
  void merge(forward_list& x);
  void merge(forward_list&& x);
  template <class Compare> void merge(forward_list& x, Compare comp);
  template <class Compare> void merge(forward_list&& x, Compare comp);
  ...
};

Add to the signatures of 23.3.3.5 [forwardlist.ops]:

void splice_after(const_iterator p, forward_list& x);
void splice_after(const_iterator p, forward_list&& x);

1 ...

void splice_after(const_iterator p, forward_list& x, const_iterator i);
void splice_after(const_iterator p, forward_list&& x, const_iterator i);

5 ...

void splice_after(const_iterator p, forward_list& x,
                const_iterator first, const_iterator last);
void splice_after(const_iterator p, forward_list&& x,
                const_iterator first, const_iterator last);

9 ...

void merge(forward_list& x);
void merge(forward_list&& x);
template <class Compare> void merge(forward_list& x, Compare comp);
template <class Compare> void merge(forward_list&& x, Compare comp);

18 ...


1318. N2982 removes previous allocator capabilities

Section: 20.9.4.1 [allocator.traits.types] Status: Ready Submitter: Pete Becker Opened: 2010-02-11 Last modified: 2010-11-12

View all issues with Ready status.

Duplicate of: 1375

Discussion:

Addresses US-87

N2982 says that containers should have a nested typedef that defines their reference_type as value_type&; the previous standard deferred to the allocator to define its reference_type, and containers simply passed the allocator's typedef on. This change is a mistake. Allocators should define both a pointer type and a reference type. That's essential for their original purpose, which was to make different memory models transparent. If an allocator defines a pointer type that isn't compatible with a normal pointer it also has to define a corresponding reference type. For example (and please forgive a Windows-ism), if an allocator's pointer is T __far*, then it's reference has to be T __far&. Otherwise everything crashes (under the hood, references are pointers and have to have the same memory access mechanics). Extensions such as this for more general memory models were explicitly encouraged by C++03, and the allocator's pointer and reference typedefs were the hooks for such extensions. Removing the allocator's reference and const_reference typedefs makes those extensions unimplementable and breaks existing implementations that rely on those hooks.

[ 2010-02-25 Alisdair adds: ]

vector<bool>::reference is a nested class, and not a typedef. It should be removed from the list of containers when this change is made.

In general, I am unfcomfortable placing this reference requirement on each container, as I would prefer to require:

is_same<Container::reference, Container::iterator::reference>

This distinction is important, if we intend to support proxy iterators. The iterator paper in the pre-Pittsburgh mailing (N3046) does not make this proposal, but organises clause 24 in such a way this will be much easier to specify.

The changes to clause 20 remain important for all the reasons Pete highlights.

[ 2010 Batavia ]

Removed vector from list of templates that should be adjusted.

Proposed resolution:

  1. Add the following two rows to Table 40, Allocator requirements:

    Table 40 — Allocator requirements
    Expression Return type Assertion/note
    pre-/post-condition
    Default
    X::reference T&
    X::const_reference const T&
  2. 2. Change the following two rows in Table 40:

    Table 40 — Allocator requirements
    Expression Return type Assertion/note
    pre-/post-condition
    Default
    *p T& X::reference
    *q const T& X::const_reference
  3. Add the following typedef declarations to allocator_traits 20.9.4 [allocator.traits]:

    template <class Alloc> struct allocator_traits {
      ...
      typedef see below reference;
      typedef see below const_reference;
      ...
    
  4. Add the following descriptions to 20.9.4.1 [allocator.traits.types]:

    typedef see below reference;
    Type: Alloc::reference if such a type exists; otherwise, value_type&.
    typedef see below const reference;
    Type: Alloc::const_reference if such a type exists; otherwise, const value_type&.
  5. Add the following typdef declarations to scoped_allocator_adaptor 20.10 [allocator.adaptor]:

    template <class OuterAlloc, class... InnerAllocs>
    class scoped_allocator_adaptor : public OuterAlloc {
      ...
      typedef typename OuterTraits::reference reference;
      typedef typename OuterTraits::const_reference const_reference;
      ...
    
  6. Change the nested typedefs reference and const_reference to:

    typedef typename allocator_traits<Allocator>::reference reference;
    typedef typename allocator_traits<Allocator>::const_reference const_reference;
    

    for each of the following class templates:

    deque 23.3.2 [deque]
    forward_list 23.3.3 [forwardlist]
    list 23.3.4 [list]
    queue 23.5.1.1 [queue.defn]
    priority_queue 23.5.2 [priority.queue]
    stack 23.5.3.1 [stack.defn]
    vector<bool> 23.4.2 [vector.bool]
    map 23.6.1 [map]
    multimap 23.6.2 [multimap]
    set 23.6.3 [set]
    multiset 23.6.4 [multiset]
    unordered_map 23.7.1 [unord.map]
    unordered_multimap 23.7.2 [unord.multimap]
    unordered_set 23.7.3 [unord.set]
    unordered_multiset 23.7.4 [unord.multiset]
    basic_string 21.4 [basic.string]
    match_results 28.10 [re.results]

1320. Header for iter_swap

Section: 24.3 [iterator.synopsis] Status: Tentatively NAD Future Submitter: Alisdair Meredith Opened: 2010-02-16 Last modified: 2010-11-13

Discussion:

The iter_swap function template appears in the <algorithm> header, yet its main use is in building further algorithms, not calling existing ones. The main clients are implementers of data structures and their iterators, so it seems most appropriate to place the template in the <iterator> header instead.

Note that this is not an issue for implementers of the standard library, as they rarely use the standard headers directly, designing a more fine-grained set of headers for their own internal use. This option is not available to customers of the standard library.

Note that we cannot remove iter_swap from <algorithm> without breaking code, but there is no reason we cannot offer the same declaration via two standard headers. Alternatively, require <algorithm> to #include <iterator>, but introducing the dependency on the iterator adaptors seems un-necessary.

[ ]

Discussed possibly moving to <utility> but don't like that. Some not seeing this as a defect, and want to keep it in <algorithm>. No one seems to feel strongly about moving to <iterator>.

Proposed resolution:

Add the declaration of iter_swap to the <iterator> header synopsis (24.3 [iterator.synopsis]), with a note that it is documented in clause 25 [algorithms].

...
template <class T, size_t N> T* end(T (&array)[N]);

// documented in 25 [algorithms]
template<class ForwardIterator1, class ForwardIterator2>
  void iter_swap(ForwardIterator1 a, ForwardIterator2 b);

1330. Move container requirements into requirements tables

Section: 23.2 [container.requirements] Status: Deferred Submitter: Nicolai Josuttis Opened: 2010-03-10 Last modified: 2010-11-15

View all other issues in [container.requirements].

View all issues with Deferred status.

Discussion:

Abstract:

In general, it seems that in a couple of places container behavior is not described in requirement tables although it is a general behavior.

History:

Issue 676 added move semantics to unordered containers. For the added insert functions the Editor requested to put their semantic description into a requirements table rather than describing them for each container individually. The text however was taken from the associative containers, where we also have the semantics for each container described. Also, 1034 is to some extend requesting a clarification of the requirement tables and it turned out that in other places we have the same problem (e.g. we have no general requirement for type pointer and const_pointer although each container has them with issue 1306).

From my personal list of functions in requirement tables and containers, the following types/functions are missing in requirement tables:

As a special case, we lack the following requirements for all sequence containers BUT array (so special wording or a new container category is required):

Note that we also might have to add additional requirements on other places for sequence containers because having an allocator requires additional statements for the treatment of the allocators. E.g. swap for containers with allocators is not specified in any requirement table.

And finally, if we have the requirements in the requirements tables, we can remove the corresponding descriptions for the individual container. However, note that sequence container requirements have NO complexity column, so that we still need container specific descriptions for the functions listed there.

[ 2010 Batavia ]

While there is consensus that further cleaning up the container requirement tables would be a good thing, there is no feeling that this must be done in time for 0x. The issue remains open, but Deferred.

Proposed resolution:


1332. Let Hash objects throw!

Section: 20.2.4 [hash.requirements] Status: Ready Submitter: Daniel Krügler Opened: 2010-03-26 Last modified: 2010-11-14

View all issues with Ready status.

Discussion:

The currently added Hash requirements demand in Table 40 — Hash requirements [hash]:

Table 40 — Hash requirements [hash]
Expression Return type Requirement
h(k) size_t Shall not throw exceptions. [..]

While it surely is a generally accepted idea that hash function objects should not throw exceptions, this basic constraint for such a fundamental requirement set does neither match the current library policy nor real world cases:

  1. There are little known situations where a swap or move operation may throw an exception and in some popular domains such functions are required not to throw. But the library invested already efforts for good reasons to require "working" container implementations in the presence of throwing move or swap operations, see e.g. 23.2.4.1 [associative.reqmts.except], 23.2.5.1 [unord.req.except].
  2. The container library is already specified to cope with potentially throwing comparers, predicates, and hash function objects, see above.
  3. The new definition goes beyond the original hash requirements as specified by SGI library in regard to the exception requirement:

    http://www.sgi.com/tech/stl/HashFunction.html
  4. There are indeed real-world examples of potentially throwing hash functions, typically when the proxy pattern is used and when the to-be hashed proxied instance is some volatile object, e.g. a file or internet resource, that might suddenly be unavailable at the time of hashing.
  5. With the new noexcept language facility libraries can still take advantage of no-throw guarantees of hasher functions with stricter guarantees.

Even though the majority of all known move, swap, and hash functions won't throw and in some cases must not throw, it seems like unnecessary over-constraining the definition of a Hash functor not to propagate exceptions in any case and it contradicts the general principle of C++ to impose such a requirement for this kind of fundamental requirement.

[ 2010-11-11 Daniel asks the working group whether they would prefer a replacement for the second bullet of the proposed resolution (a result of discussing this with Alberto) of the form: ]

Add to 20.8.15 [unord.hash]/1 a new bullet:

1 The unordered associative containers defined in Clause 23.5 use specializations of the class template hash as the default hash function. For all object types Key for which there exists a specialization hash<Key>, the instantiation hash<Key> shall:

[Batavia: Closed as NAD Future, then reopened. See the wiki for Tuesday.]

Proposed resolution:

  1. Change Table 40 — Hash requirements [hash] as indicated:

    Table 40 — Hash requirements [hash]
    Expression Return type Requirement
    h(k) size_t Shall not throw exceptions. [..]
  2. Add to 20.8.15 [unord.hash]/1 a new bullet:

    1 The unordered associative containers defined in Clause 23.5 use specializations of the class template hash as the default hash function. For all object types Key for which there exists a specialization hash<Key>, the instantiation hash<Key> shall:

    • satisfy the Hash requirements (20.2.4), with Key as the function call argument type, the DefaultConstructible requirements (33), the CopyAssignable requirements (37),
    • be swappable (20.2.2) for lvalues,
    • provide two nested types result_type and argument_type which shall be synonyms for size_t and Key, respectively,
    • satisfy the requirement that if k1 == k2 is true, h(k1) == h(k2) is also true, where h is an object of type hash<Key> and k1 and k2 are objects of type Key,.
    • satisfy the requirement that the expression h(k), where h is an object of type hash<Key> and k is an object of type Key, shall not throw an exception, unless hash<Key> is a user-defined specialization that depends on at least one user-defined type.

1345. [FCD] Library classes should have noexcept move operations

Section: 17 [library] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-31

View other active issues in [library].

View all other issues in [library].

View all issues with Open status.

Discussion:

Addresses GB-61

All library types should have non-throwing move constructors and move-assignment operators unless wrapping a type with a potentially throwing move operation. When such a type is a class-template, these operations should have a conditional noexcept specification.

There are many other places where a noexcept specification may be considered, but the move operations are a special case that must be called out, to effectively support the move_if_noexcept function template.

[ Resolution proposed by ballot comment: ]

Review every class and class template in the library. If noexcept move constructor/assignment operators can be implicitly declared, then they should be implicitly declared, or explicitly defaulted. Otherwise, a move constructor/moveassingment operator with a noexcept exception specification should be provided.

[ 2010-10-31 Daniel comments: ]

The proposed resolution of n3157 would satisfy this request.

Proposed resolution:

See n3157

1348. [FCD] Exception safety of unspecified types

Section: 17 [library] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-25

View other active issues in [library].

View all other issues in [library].

View all issues with Open status.

Discussion:

Addresses GB-64

There are a number of unspecified types used throughout the library, such as the container iterators. Many of these unspecified types have restrictions or expectations on their behaviour in terms of exceptions. Are they permitted or required to use exception specifications, more specifically the new noexcept specification? For example, if vector<T>::iterator is implemented as a native pointer, all its operations will have an (effective) noexcept specification. If the implementation uses a class type to implement this iterator, is it permitted or required to support that same guarantee?

[ Resolution proposed by ballot comment ]

Clearly state the requirements for exception specifications on all unspecified library types. For example, all container iterator operations should be conditionally noexcept, with the condition matching the same operation applied to the allocator's pointer_type, a certain subset of which are already required not to throw.

Proposed resolution:


1349. [FCD] swap should not throw

Section: 17 [library] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-25

View other active issues in [library].

View all other issues in [library].

View all issues with Open status.

Discussion:

Addresses GB-65

Nothrowing swap operations are key to many C++ idioms, notably the common copy/swap idiom to provide the strong exception safety guarantee.

[ Resolution proposed by ballot comment ]

Where possible, all library types should provide a swap operation with an exception specification guaranteeing no exception shall propagate. Where noexcept(true) cannot be guaranteed to not terminate the program, and the swap in questions is a template, an exception specification with the appropriate conditional expression could be specified.

Proposed resolution:


1353. [FCD] Clarify the state of a moved-from object

Section: 17 [library] Status: Open Submitter: Switzerland Opened: 2010-08-25 Last modified: 2010-11-14

View other active issues in [library].

View all other issues in [library].

View all issues with Open status.

Discussion:

Addresses CH-18

The general approach on moving is that a library object after moving out is in a "valid but unspecified state". But this is stated at the single object specifications, which is error prone (especially if the move operations are implicit) and unnecessary duplication.

[ Resolution propsed by ballot comment ]

Consider putting a general statement to the same effect into clause 17.

[2010-11-05 Beman provides exact wording. The wording was inspired by Dave Abrahams' message c++std-lib-28958, and refined with help from Alisdair, Daniel, and Howard. ]

Proposed resolution:

Add a new definition to 17.3 Definitions [definitions]:

17.3.24 [defns.valid.unspecified]
valid but unspecified state
an object state that is not specified except that the object's invariants are met, and operations on the object perform as specified, subject only to the operation's normal preconditions.

[Example: If an object x of type std::vector<int> is in a valid but unspecified state, x.empty() can be called unconditionally, and x.front() can be called provided x.empty() returns false. --end example]

Change Table 34 - MoveConstructible requirements [moveconstructible] as indicated:

[ Note: rv remains a valid object. Its state is unspecified  --end note ]
Postcondition: rv is in a valid but unspecified state ([defns.valid.unspecified]).

Change Table 36 - MoveAssignable requirements [moveassignable] as indicated:

[ Note: rv remains a valid object. Its state is unspecified  --end note ]
Postcondition: rv is in a valid but unspecified state ([defns.valid.unspecified]).

No change in the half-dozen or so places in the standard library that use "valid but unspecified state" directly, and no change in the many places that require MoveCostructible or MoveAssignable, since MoveCostructible and MoveAssignable will now normatively require "valid but unspecified state".


1358. [FCD] Add <chrono> and <ratio> to freestanding implementations

Section: 17.6.1.3 [compliance] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-29

View all other issues in [compliance].

View all issues with Open status.

Discussion:

Addresses GB-55

The <thread> header uses duration types, found in the <chrono> header, and which rely on the ratio types declared in the <ratio> header.

[ Extracts from lengthy Rapperswil discussion: ]

There is a concern that this issue is a misunderstanding of the actual requirements of a free-standing implementation to support the <thread> header. In general, a free-standanding implementation will provide an empty header, specifically so that a user can test for the absence of the _ _ STDCPP_THREADS _ _ macro. This idiom as used as there is no portable way to test for the lack of a header.

At this point, it was suggested the NB comment is trying to solve the wrong problem, and that _ _ STDCPP_THREADS _ _ should be a pre-defined macro in clause 16 that can be tested before including <thread>. That would remove the need to add additional headers to the free-standanding requirements.

It is worth noting that Japan requested <ratio> as a free-standing header in their CD1 comments. No-one seemed keen to require clocks of a free-standing implementation though.

Detlef volunteers to look at a way to redraft 17.6.1.3 p3.

[ Original resolution proposed by NB comment: ]

Add the <chrono> and <ratio> headers to the freestanding requirements.

It might be necessary to address scaled-down expectations of clock support in a freestanding environment, much like <thread>.

Proposed resolution:


1364. [FCD] It is not clear how exception_ptr is synchronized

Section: 18.8.5 [propagation] Status: Open Submitter: Switzerland Opened: 2010-08-25 Last modified: 2010-10-24

View other active issues in [propagation].

View all other issues in [propagation].

View all issues with Open status.

Discussion:

Addresses CH-19

It is not clear how exception_ptr is synchronized.

[ Resolution proposed by ballot comment ]

Make clear that accessing in different threads multiple exception_ptr objects that all refer to the same exception introduce a race.

Proposed resolution:


1369. [FCD] rethrow_exception may introduce data races

Section: 18.8.5 [propagation] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-24

View other active issues in [propagation].

View all other issues in [propagation].

View all issues with Open status.

Discussion:

Addresses GB-74

One idea for the exception_ptr type was that a reference-counted implementation could simply 'reactivate' the same exception object in the context of a call to rethrow_exception. Such an implementation would allow the same exception object to be active in multiple threads (such as when multiple threads join on a shared_future) and introduce potential data races in any exception handler that catches exceptions by reference - notably existing library code written before this capability was added. rethrow_exception should always make a copy of the target exception object.

Proposed resolution:

Add the following to 18.8.5, [propogation]

Throws: a copy of the exception object to which p refers.

1371. [FCD] standard exceptions require stronger no-throw guarantees

Section: 19 [diagnostics] Status: Tentatively NAD Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all issues with Tentatively NAD status.

Discussion:

Addresses GB-75

None of the exception types defined in clause 19 are allowed to throw an exception on copy or move operations, but there is no clear specification that the operations have an exception specification to prove it. Note that the implicitly declared constructors, taking the exception specification from their base class (ultimately std::exception) will implicitly generate a noexcept exception specification if all of their data members similarly declare noexcept operations. As the representation is unspecified, we cannot assume nonthrowing operations unless we explicitly state this as a constraint on the implementation.

[ Resolution proposed by ballot comment: ]

Add a global guarantee that all exception types defined in clause 19 that rely on implicitly declared operations have a non-throwing exception specification on those operations.

[ 2010 Batavia: ]

This is addressed by the current words in 18.8.1 [exception], p2

Each standard library class T that derives from class exception shall have a publicly accessible copy constructor and a publicly accessible copy assignment operator that do not exit with an exception.

Proposed resolution:


1374. [FCD] Clarify moved-from objects are "toxic"

Section: 20.2.1 [utility.arg.requirements] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View all other issues in [utility.arg.requirements].

View all issues with Open status.

Discussion:

Addresses US-85

20.2.1 Table 34 "MoveConstructible requirements" says "Note: rv remains a valid object. Its state is unspecified". Some components give stronger guarantees. For example, moved-from shared_ptrs are guaranteed empty (20.9.11.2.1/25). In general, what the standard really should say (preferably as a global blanket statement) is that moved-from objects can be destroyed and can be the destination of an assignment. Anything else is radioactive. For example, containers can be "emptier than empty". This needs to be explicit and required generally.

Note: The last time that one of us mentioned "emptier than empty" (i.e. containers missing sentinel nodes, etc.) the objection was that containers can store sentinel nodes inside themselves in order to avoid dynamically allocating them. This is unacceptable because

(a) it forces existing implementations (i.e. Dinkumware's, Microsoft's, IBM's, etc.) to change for no good reason (i.e. permitting more operations on moved-from objects), and

(b) it invalidates end-iterators when swapping containers. (The Working Paper currently permits end-iterator invalidation, which we consider to be wrong, but that's a separate argument. In any event, mandating end-iterator invalidation is very different from permitting it.)

[ Resolution proposed in ballot comment ]

State as a general requirement that moved-from objects can be destroyed and can be the destination of an assignment. Any other use is undefined behavior.

Proposed resolution:


1385. [FCD] tuple_cat should be a single variadic signature

Section: 20.4.2.4 [tuple.creation] Status: Ready Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all other issues in [tuple.creation].

View all issues with Ready status.

Discussion:

Addresses GB-88

The tuple_cat template consists of four overloads and that can concatenate only two tuples. A single variadic signature that can concatenate an arbitrary number of tuples would be preferred.

[ Resolution proposed by ballot comment: ]

Adopt a simplified form of the proposal in n2975, restricted to tuples and neither requiring nor outlawing support for other tuple-like types.

[ 2010 Rapperswil: Alisdair to provide wording. ]

[ 2010-11-06: Daniel comments and proposes some alternative wording: ]

There are some problems in the wording: First, even though the result type tuple<see below> implies it, the specification of the contained tuple element types is missing. Second, the term "tuple protocol" is not defined anywhere and I see no reason why this normative wording should not be a non-normative note. We could at least give a better approximation, maybe "tuple-like protocol" as indicated from header <utility> synopsis. Further, it seems to me that the effects need to contain a combination of std::forward with the call of get. Finally I suggest to replace the requirements Move/CopyConstructible by proper usage of is_constructible, as indicated by n3140.

[ 2010 Batavia ]

Moved to Ready with Daniel's improved wording.

Proposed resolution:

Note: This alternate proposed resolution works only if 1191 has been accepted.

  1. Change 20.4.1 [tuple.general] p. 2, header <tuple> synopsis, as indicated:
    namespace std {
    
    ...
    
    // 20.4.2.4, tuple creation functions:
    const unspecified ignore;
    
    template <class... Types>
      tuple<VTypes...> make_tuple(Types&&...);
      template <class... Types>
      tuple<ATypes...> forward_as_tuple(Types&&...);
      
    template<class... Types>
      tuple<Types&...> tie(Types&...);
      
    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(const tuple<TTypes...>&, const tuple<UTypes...>&);
    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(tuple<TTypes...>&&, const tuple<UTypes...>&);
    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(const tuple<TTypes...>&, tuple<UTypes...>&&);
    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(tuple<TTypes...>&&, tuple<UTypes...>&&);
    template <class... Tuples>
      tuple<CTypes...> tuple_cat(Tuples&&...);
    
    ...
    
    
  2. Change 20.4.2.4 [tuple.creation] as indicated:
    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>& u);

    8 Requires: All the types in TTypes shall be CopyConstructible (Table 35). All the types in UTypes shall be CopyConstructible (Table 35).

    9 Returns: A tuple object constructed by copy constructing its first sizeof...(TTypes) elements from the corresponding elements of t and copy constructing its last sizeof...(UTypes) elements from the corresponding elements of u.

    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(tuple<TTypes...>&& t, const tuple<UTypes...>& u);

    10 Requires: All the types in TTypes shall be MoveConstructible (Table 34). All the types in UTypes shall be CopyConstructible (Table 35).

    11 Returns: A tuple object constructed by move constructing its first sizeof...(TTypes) elements from the corresponding elements of t and copy constructing its last sizeof...(UTypes) elements from the corresponding elements of u.

    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(const tuple<TTypes...>& t, tuple<UTypes...>&& u);

    12 Requires: All the types in TTypes shall be CopyConstructible (Table 35). All the types in UTypes shall be MoveConstructible (Table 34).

    13 Returns: A tuple object constructed by copy constructing its first sizeof...(TTypes) elements from the corresponding elements of t and move constructing its last sizeof...(UTypes) elements from the corresponding elements of u.

    template <class... TTypes, class... UTypes>
      tuple<TTypes..., UTypes...> tuple_cat(tuple<TTypes...>&& t, tuple<UTypes...>&& u);

    14 Requires: All the types in TTypes shall be MoveConstructible (Table 34). All the types in UTypes shall be MoveConstructible (Table 34).

    15 Returns: A tuple object constructed by move constructing its first sizeof...(TTypes) elements from the corresponding elements of t and move constructing its last sizeof...(UTypes) elements from the corresponding elements of u.

    template <class... Tuples>
      tuple<CTypes...> tuple_cat(Tuples&&... tpls);
    

    8 Let Ti be the ith type in Tuples, Ui be remove_reference<Ti>::type, and tpi be the ith parameter in the function parameter pack tpls, where all indexing is zero-based in the following paragraphs of this sub-clause [tuple.creation].

    9 Requires: For all i, Ui shall be the type cvi tuple<Argsi...>, where cvi is the (possibly empty) ith cv-qualifier-seq, and Argsi is the parameter pack representing the element types in Ui. Let Aik be the kith type in Argsi, then for all Aik the following requirements shall be satisfied: If Ti is deduced as an lvalue reference type, then is_constructible<Aik, cvi Aik&>::value == true, otherwise is_constructible<Aik, cvi Aik&&>::value == true.

    10 Remarks: The types in CTypes shall be equal to the ordered sequence of the expanded types Args0..., Args1..., Argsn-1..., where n equals sizeof...(Tuples). Let ei... be the ith ordered sequence of tuple elements of the result tuple object corresponding to the type sequence Argsi.

    11 Returns: A tuple object constructed by initializing the kith type element eik in ei... with get<ki>(std::forward<Ti>(tpi)) for each valid ki and each element group ei in order.

    12 [Note: An implementation may support additional types in the parameter pack Tuples, such as pair and array that support the tuple-like protocol. -- end note]


1396. [FCD] regex should support allocators

Section: 28.8 [re.regex] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-07

View all other issues in [re.regex].

View all issues with Open status.

Duplicate of: 1451

Discussion:

Addresses US-104, US-141

std::basic_regex should have an allocator for all the reasons that a std::string does. For example, I can use boost::interprocess to put a string or vector in shared memory, but not a regex.

[ Resolution proposed by ballot comment ]

Add allocators to regexes

[ 2010-10-24 Daniel adds: ]

Accepting n3171 would solve this issue.

Proposed resolution:

See n3171.

1401. [FCD] unique_ptr<T> == nullptr

Section: 20.9 [memory] Status: Ready Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all other issues in [memory].

View all issues with Ready status.

Discussion:

Addresses GB-99

One reason that the unique_ptr constructor taking a nullptr_t argument is not explicit is to allow conversion of nullptr to unique_ptr in contexts like equality comparison. Unfortunately operator== for unique_ptr is a little more clever than that, deducing template parameters for both arguments. This means that nullptr does not get deduced as unique_ptr type, and there are no other comparison functions to match.

[ Resolution proposed by ballot comment: ]

Add the following signatures to 20.9 [memory] p.1, <memory> header synopsis:
template<typename T, typename D>
bool operator==(const unique_ptr<T, D> & lhs, nullptr_t);
template<typename T, typename D>
bool operator==(nullptr_t, const unique_ptr<T, D> & rhs);
template<typename T, typename D>
bool operator!=(const unique_ptr<T, D> & lhs, nullptr_t);
template<typename T, typename D>
bool operator!=(nullptr_t, const unique_ptr<T, D> & rhs);

[ 2010-11-02 Daniel comments and provides a proposed resolution: ]

The same problem applies to shared_ptr as well: In both cases there are no conversions considered because the comparison functions are templates. I agree with the direction of the proposed resolution, but I believe it would be very surprising and inconsistent, if given a smart pointer object p, the expression p == nullptr would be provided, but not p < nullptr and the other relational operators. According to 5.9 [expr.rel] they are defined if null pointer values meet other pointer values, even though the result is unspecified for all except some trivial ones. But null pointer values are nothing special here: The Library already defines the relational operators for both unique_ptr and shared_ptr and the outcome of comparing non-null pointer values will be equally unspecified. If the idea of supporting nullptr_t arguments for relational operators is not what the committee prefers, I suggest at least to consider to remove the existing relational operators for both unique_ptr and shared_ptr for consistency. But that would not be my preferred resolution of this issue.

The number of overloads triple the current number, but I think it is much clearer to provide them explicitly instead of adding wording that attempts to say that "sufficient overloads" are provided. The following proposal makes the declarations explicit.

Additionally, the proposal adds the missing declarations for some shared_ptr comparison functions for consistency.

[ 2010-11-03 Daniel adds: ]

Issue 1297 is remotely related. The following proposed resolution splits this bullet into sub-bullets A and B. Sub-bullet A would also solve 1297, but sub-bullet B would not.

A further remark in regard to the proposed semantics of the ordering of nullptr against other pointer(-like) values: One might think that the following definition might be superior because of simplicity:

template<class T>
bool operator<(const shared_ptr<T>& a, nullptr_t);
template<class T>
bool operator>(nullptr_t, const shared_ptr<T>& a);
Returns: false.
The underlying idea behind this approach is the assumption that nullptr corresponds to the least ordinal pointer value. But this assertion does not hold for all supported architectures, therefore this approach was not followed because it would lead to the inconsistency, that the following assertion could fire:

shared_ptr<int> p(new int);
shared_ptr<int> null;
bool v1 = p < nullptr;
bool v2 = p < null;
assert(v1 == v2);

Proposed resolution:

Wording changes are against N3126.

  1. Change 20.9 [memory] p. 1, header <memory> synopsis as indicated. noexcept specifications are only added, where the guarantee exists, that the function shall no throw an exception (as replacement of "Throws: Nothing". This needs to be harmonized with the result of the noexcept proposals:
    namespace std {
      [..]
      // 20.9.10 Class unique_ptr:
      template <class T> class default_delete;
      template <class T> class default_delete<T[]>;
      template <class T, class D = default_delete<T>> class unique_ptr;
      template <class T, class D> class unique_ptr<T[], D>;
    
      template <class T1, class D1, class T2, class D2>
      bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    
      template <class T, class D>
      bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator==(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      template <class T, class D>
      bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator!=(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      template <class T, class D>
      bool operator<(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator<(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator<=(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator>(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator>(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator>=(nullptr_t, const unique_ptr<T, D>& x);
      
      // 20.9.11.1, Class bad_weak_ptr:
      class bad_weak_ptr;
    
      // 20.9.11.2, Class template shared_ptr:
      template<class T> class shared_ptr;
    
      // 20.9.11.2.7, shared_ptr comparisons:
      template<class T, class U>
      bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b);
      template<class T, class U>
      bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b);
      template<class T, class U>
      bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b);
      template<class T, class U>
      bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b);
      template<class T, class U>
      bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b);
      template<class T, class U>
      bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b);
    
      template<class T>
      bool operator==(shared_ptr<T> const& a, nullptr_t) noexcept;
      template<class T>
      bool operator==(nullptr_t, shared_ptr<T> const& a) noexcept;
      template<class T>
      bool operator!=(shared_ptr<T> const& a, nullptr_t) noexcept;
      template<class T>
      bool operator!=(nullptr_t, shared_ptr<T> const& a) noexcept;
      template<class T>
      bool operator<(shared_ptr<T> const& a, nullptr_t) noexcept;
      template<class T>
      bool operator<(nullptr_t, shared_ptr<T> const& a) noexcept;
      template>class T>
      bool operator>(shared_ptr<T> const& a, nullptr_t) noexcept;
      template>class T>
      bool operator>(nullptr_t, shared_ptr<T> const& a) noexcept;
      template<class T>
      bool operator<=(shared_ptr<T> const& a, nullptr_t) noexcept;
      template<class T>
      bool operator<=(nullptr_t, shared_ptr<T> const& a) noexcept;
      template>class T>
      bool operator>=(shared_ptr<T> const& a, nullptr_t) noexcept;
      template>class T>
      bool operator>=(nullptr_t, shared_ptr<T> const& a) noexcept;
    
      [..]
    }
    
  2. Change the synopsis just after 20.9.9 [unique.ptr] p. 6 as indicated:
    namespace std {
      [..]
      
      template <class T1, class D1, class T2, class D2>
      bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      template <class T1, class D1, class T2, class D2>
      bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
    
      template <class T, class D>
      bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator==(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      template <class T, class D>
      bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator!=(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      template <class T, class D>
      bool operator<(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator<(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator<=(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator>(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator>(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator>=(nullptr_t, const unique_ptr<T, D>& x);
    
    }
    
  3. This bullet splits into two sub-bullets A and B as mentioned in the discussion comment:
    1. Change 20.9.9.4 [unique.ptr.special]/4-7 as indicated and add a series of prototype descriptions:
      template <class T1, class D1, class T2, class D2>
        bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      

      ? Requires: Let CT be common_type<unique_ptr<T1, D1>::pointer, unique_ptr<T2, D2>::pointer>::type. Then the specialization less<CT> shall be a function object type ([function.objects]) that induces a strict weak ordering ([alg.sorting]) on the pointer values.

      4 Returns: less<CT>()(x.get(), y.get())x.get() < y.get().

      ? Remarks: If unique_ptr<T1, D1>::pointer is not implicitly convertible to CT or unique_ptr<T2, D2>::pointer is not implicitly convertible to CT, the program is ill-formed.

      template <class T1, class D1, class T2, class D2>
        bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      
      5 Returns: !(y < x)x.get() <= y.get().
      template <class T1, class D1, class T2, class D2>
        bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      
      6 Returns: (y < x)x.get() > y.get().
      template <class T1, class D1, class T2, class D2>
        bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
      
      7 Returns: !(x < y)x.get() >= y.get().
      template <class T, class D>
      bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator==(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      
      ? Returns: !x.
      template <class T, class D>
      bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator!=(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      
      ? Returns: (bool) x.
      template <class T, class D>
      bool operator<(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator>(nullptr_t, const unique_ptr<T, D>& x);
      
      ? Requires: The specialization less<unique_ptr<T, D>::pointer> shall be a function object type ([function.objects]) that induces a strict weak ordering ([alg.sorting]) on the pointer values.
      ? Returns: less<unique_ptr<T, D>::pointer>()(x.get(), nullptr).
      template <class T, class D>
      bool operator<(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator>(const unique_ptr<T, D>& x, nullptr_t);
      
      ? Requires: The specialization less<unique_ptr<T, D>::pointer> shall be a function object type ([function.objects]) that induces a strict weak ordering ([alg.sorting]) on the pointer values.
      ? Returns: less<unique_ptr<T, D>::pointer>()(nullptr, x.get()).
      template <class T, class D>
      bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
      template <class T, class D>
      bool operator>=(nullptr_t, const unique_ptr<T, D>& x);
      
      ? Returns: !(nullptr < x).
      template <class T, class D>
      bool operator<=(nullptr_t, const unique_ptr<T, D>& x);
      template <class T, class D>
      bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
      
      ? Returns: !(x < nullptr).
    2. Add the following series of prototype specifications at the very end of 20.9.9.4 [unique.ptr.special]. Intentionally, the relational operators are defined individually, because there is no guarantee that from x.get() < nullptr follows the relation nullptr > x.get():
      template <class T, class D>
      bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator==(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      
      ? Returns: !x.
      template <class T, class D>
      bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
      template <class T, class D>
      bool operator!=(nullptr_t, const unique_ptr<T, D>& x) noexcept;
      
      ? Returns: (bool) x.
      template <class T, class D>
      bool operator<(const unique_ptr<T, D>& x, nullptr_t);
      
      ? Returns: x.get() < nullptr.
      template <class T, class D>
      bool operator<(nullptr_t, const unique_ptr<T, D>& x);
      
      ? Returns: nullptr < x.get().
      template <class T, class D>
      bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
      
      ? Returns: x.get() <= nullptr.
      template <class T, class D>
      bool operator<=(nullptr_t, const unique_ptr<T, D>& x);
      
      ? Returns: nullptr <= x.get().
      template <class T, class D>
      bool operator>(const unique_ptr<T, D>& x, nullptr_t);
      
      ? Returns: x.get() > nullptr.
      template <class T, class D>
      bool operator>(nullptr_t, const unique_ptr<T, D>& x);
      
      ? Returns: nullptr > x.get().
      template <class T, class D>
      bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
      
      ? Returns: x.get() >= nullptr.
      template <class T, class D>
      bool operator>=(nullptr_t, const unique_ptr<T, D>& x);
      
      ? Returns: nullptr >= x.get().
  4. Change 20.9.10.2 [util.smartptr.shared] p. 1, class template shared_ptr synopsis as indicated. For consistency reasons the remaining normal relation operators are added as well:
    namespace std {
      [..]
      // 20.9.11.2.7, shared_ptr comparisons:
      template<class T, class U>
      bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b);
      template<class T, class U>
      bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b);
      template<class T, class U>
      bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b);
      template<class T, class U>
      bool operator>(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
      template<class T, class U>
      bool operator<=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
      template<class T, class U>
      bool operator>=(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
    
      template<class T>
      bool operator==(const shared_ptr<T>& a, nullptr_t) noexcept;
      template<class T>
      bool operator==(nullptr_t, const shared_ptr<T>& a) noexcept;
      template<class T>
      bool operator!=(const shared_ptr<T>& a, nullptr_t) noexcept;
      template<class T>
      bool operator!=(nullptr_t, const shared_ptr<T>& a) noexcept;
      template<class T>
      bool operator<(const shared_ptr<T>& a, nullptr_t) noexcept;
      template<class T>
      bool operator<(nullptr_t, const shared_ptr<T>& a) noexcept;
      template>class T>
      bool operator>(const shared_ptr<T>& a, nullptr_t) noexcept;
      template>class T>
      bool operator>(nullptr_t, const shared_ptr<T>& a) noexcept;
      template<class T>
      bool operator<=(const shared_ptr<T>& a, nullptr_t) noexcept;
      template<class T>
      bool operator<=(nullptr_t, const shared_ptr<T>& a) noexcept;
      template>class T>
      bool operator>=(const shared_ptr<T>& a, nullptr_t) noexcept;
      template>class T>
      bool operator>=(nullptr_t, const shared_ptr<T>& a) noexcept;
    
      [..]
    }
    
  5. Add the following series of prototype specifications at the very end of 20.9.10.2.7 [util.smartptr.shared.cmp]. For mixed comparison the general "generation" rule of 20.3.1 [operators] p. 10 does not apply, therefore all of them are defined. Below wording takes advantage of the simplified definition of the composite pointer type if one partner is a null pointer constant:
    template<class T>
    bool operator==(const shared_ptr<T>& a, nullptr_t) noexcept;
    template<class T>
    bool operator==(nullptr_t, const shared_ptr<T>& a) noexcept;
    
    ? Returns: !a.
    template<class T>
    bool operator!=(const shared_ptr<T>& a, nullptr_t) noexcept;
    template<class T>
    bool operator!=(nullptr_t, const shared_ptr<T>& a) noexcept;
    
    ? Returns: (bool) a.
    template<class T>
    bool operator<(const shared_ptr<T>& a, nullptr_t) noexcept;
    template<class T>
    bool operator>(nullptr_t, const shared_ptr<T>& a) noexcept;
    
    ? Returns: less<T*>()(a.get(), nullptr).
    template<class T>
    bool operator<(nullptr_t, const shared_ptr<T>& a) noexcept;
    template<class T>
    bool operator>(const shared_ptr<T>& a, nullptr_t) noexcept;
    
    ? Returns: less<T*>()(nullptr, a.get()).
    template<class T>
    bool operator<=(const shared_ptr<T>& a, nullptr_t) noexcept;
    template<class T>
    bool operator>=(nullptr_t, const shared_ptr<T>& a) noexcept;
    
    ? Returns: !(nullptr < a).
    template<class T>
    bool operator<=(nullptr_t, const shared_ptr<T>& a) noexcept;
    template<class T>
    bool operator>=(const shared_ptr<T>& a, nullptr_t) noexcept;
    
    ? Returns: !(a < nullptr).

1408. [FCD] Allow recycling of pointers after undeclare_no_pointers

Section: 20.9.11 [util.dynamic.safety] Status: Ready Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all other issues in [util.dynamic.safety].

View all issues with Ready status.

Discussion:

Addresses GB-103

The precondition to calling declare_no_pointers is that no bytes in the range "have been previously registered" with this call. As written, this precondition includes bytes in ranges, even after they have been explicitly unregistered with a later call to undeclare_no_pointers.

Proposed resolution:

Update 20.9.11 [util.dynamic.safety] p.9:

void declare_no_pointers(char *p, size_t n);
9 Requires: No bytes in the specified range have been previously registeredare currently registered with declare_no_pointers(). If the specified range is in an allocated object, then it must be entirely within a single allocated object. The object must be live until the corresponding undeclare_no_pointers() call. [..]

1413. [FCD] Specify whether high_resolution_clock is a distinct type or a typedef

Section: 20.11.5.3 [time.clock.hires] Status: Tentatively NAD Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-14

View all issues with Tentatively NAD status.

Discussion:

Addresses US-112

What it means for high_resolution_clock to be a synonym is undefined. If it may or may not be a typedef, then certain classes of programs become unportable.

[ Resolution proposed in ballot comment ]

Require that it be a distinct class type.

[ 2010 Batavia ]

This is not a defect. Threre are a number of places in the standard where we allow implentations to choose their preferred technique, the most obvious example being the iterator/const_iterator types of set.

Typically, this means it is not portable to declare function overloads that differ only in their use of these types.

Proposed resolution:


1418. [FCD] Effects of resize(size()) on a deque

Section: 23.3.2.2 [deque.capacity] Status: Ready Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all other issues in [deque.capacity].

View all issues with Ready status.

Discussion:

Addresses GB-113

There is no mention of what happens if sz==size(). While it obviously does nothing I feel a standard needs to say this explicitely.

[ 2010 Batavia ]

Accepted with a simplified resolution turning one of the < comparisons into <=.

Proposed resolution:

Ammend [deque.capacity]

void resize(size_type sz);

Effects: If sz <= size(), equivalent to erase(begin() + sz, end());. If size() < sz, appends sz - size() default constructedvalue initialized elements to the sequence.


1420. [FCD] Effects of resize(size()) on a list

Section: 23.3.4.2 [list.capacity] Status: Ready Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all other issues in [list.capacity].

View all issues with Ready status.

Discussion:

Addresses GB-115

There is no mention of what happens if sz==size(). While it obviously does nothing I feel a standard needs to say this explicitely.

[ Resolution proposed in ballot comment ]

Express the semantics as pseudo-code similarly to the way it is done for the copying overload that follows (in p3). Include an else clause that does nothing and covers the sz==size() case.

[ 2010 Batavia ]

Accepted with a simplified resolution turning one of the < comparisons into <=.

Proposed resolution:

Ammend [list.capacity] p1:

void resize(size_type sz);

Effects: If sz <= size(), equivalent to list<T>::iterator it = begin(); advance(it, sz); erase(it, end());. If size() < sz, appends sz - size() default constructed value initialized elements to the sequence.

1421. [FCD] Accidental move-only library types due to new core language rules

Section: 23.5 [container.adaptors] Status: Open Submitter: DIN Opened: 2010-08-25 Last modified: 2010-10-26

View all other issues in [container.adaptors].

View all issues with Open status.

Duplicate of: 1350

Discussion:

Addresses DE-22, CH-15

With the final acceptance of move operations as special members and introduction of corresponding suppression rules of implicitly generated copy operations the some library types that were copyable in C++03 are no longer copyable (only movable) in C++03, among them queue, priority_queue, and stack.

[ 2010-10-26: Daniel comments: ]

Accepting n3112 should fix this.

Proposed resolution:

See n3112

1438. [FCD] No definition for base()

Section: 26.5.4.1 [rand.adapt.disc] Status: Ready Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-29

View all other issues in [rand.adapt.disc].

View all issues with Ready status.

Discussion:

Addresses US-126

Each adaptor has a member function called base() which has no definition.

[ Resolution proposed by ballot comment: ]

Give it the obvious definition.

[ 2010-11-03 Daniel comments and provides a proposed resolution: ]

The following proposal adds noexcept specifiers to the declarations of the base() functions as replacement for a "Throws: Nothing" element.

[ 2010 Batavia: The working group reviewed this issue, and recommended to add the following to the Proposed Resolution.

After further review, the working group concurred with the Proposed Resolution. ]

[Batavia: waiting for WEB to review wording]

Proposed resolution:

  1. Add the following sentence to the end of 26.5.1.5 [rand.req.adapt]/1:
    A random number engine adaptor (commonly shortened to adaptor) a of type A is a random number engine that takes values produced by some other random number engine, and applies an algorithm to those values in order to deliver a sequence of values with different randomness properties. An engine b of type B adapted in this way is termed a base engine in this context. The expression a.base() shall be valid and shall return a const reference to a's base engine.
  2. Change in [rand.adapt.disc]/3, class template discard_block_engine synopsis, the following declaration:
    // property functions
    const Engine& base() const noexcept;
    
  3. Add the following new prototype description at the end of sub-clause 26.5.4.1 [rand.adapt.disc]:
    const Engine& base() const noexcept;
    
    ? Returns: e.
  4. Change in [rand.adapt.ibits]/4, class template independent_bits_engine synopsis, the following declaration:
    // property functions
    const Engine& base() const noexcept;
    
  5. Add the following new prototype description at the end of sub-clause 26.5.4.2 [rand.adapt.ibits]:
    const Engine& base() const noexcept;
    
    ? Returns: e.
  6. Change in 26.5.4.3 [rand.adapt.shuf]/3, class template shuffle_order_engine synopsis, the following declaration:
    // property functions
    const Engine& base() const noexcept;
    
  7. Add the following new prototype description at the end of sub-clause 26.5.4.3 [rand.adapt.shuf]:
    const Engine& base() const noexcept;
    
    ? Returns: e.

1448. [FCD] Concerns about basic_stringbuf::str(basic_string) postconditions

Section: 27.8.1.3 [stringbuf.members] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View all issues with Open status.

Discussion:

Addresses GB-124

N3092 27.8.1.3 [stringbuf.members] contains this textcspecifying the postconditions of basic_stringbuf::str(basic_string):

Postconditions: If mode & ios_base::out is true, pbase() points to the first underlying character and epptr() >= pbase() + s.size() holds; in addition, if mode & ios_base::in is true, pptr() == pbase() + s.data() holds, otherwise pptr() == pbase() is true. [...]

Firstly, there's a simple mistake: It should be pbase() + s.length(), not pbase() + s.data().

Secondly, it doesn't match existing implementations. As far as I can tell, GCC 4.5 does not test for mode & ios_base::in in the second part of that sentence, but for mode & (ios_base::app | ios_base_ate), and Visual C++ 9 for mode & ios_base::app. Besides, the wording of the C++0x draft doesn't make any sense to me. I suggest changing the second part of the sentence to one of the following:

Replace ios_base::in with (ios_base::ate | ios_base::app), but this would require Visual C++ to change (replacing only with ios_base::ate would require GCC to change, and would make ios_base::app completely useless with stringstreams):

in addition, if mode & (ios_base::ate | ios_base::app) is true, pptr() == pbase() + s.length() holds, otherwise pptr() == pbase() is true.

Leave pptr() unspecified if mode & ios_base::app, but not mode & ios_base::ate (implementations already differ in this case, and it is always possible to use ios_base::ate to get the effect of appending, so it is not necessary to require any implementation to change):

in addition, if mode & ios_base::ate is true, pptr() == pbase() + s.length() holds, if neither mode & ios_base::ate nor mode & ios_base::app is true, pptr() == pbase() holds, otherwise pptr() >= pbase() && pptr() <= pbase() + s.length() (which of the values in this range is unspecified).

Slightly stricter:

in addition, if mode & ios_base::ate is true, pptr() == pbase() + s.length() holds, if neither mode & ios_base::ate nor mode & ios_base::app is true, pptr() == pbase() holds, otherwise pptr() == pbase() || pptr() == pbase() + s.length() (which of these two values is unspecified). A small table might help to better explain the three cases. BTW, at the end of the postconditions is this text: "egptr() == eback() + s.size() hold". Is there a perference for basic_string::length or basic_string::size? It doesn't really matter, but it looks a bit inconsistent.

Proposed resolution:


1450. [FCD] Contradiction in regex_constants

Section: 28.5.2 [re.matchflag] Status: Deferred Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-13

View all issues with Deferred status.

Discussion:

Addresses GB-127

The Bitmask Type requirements in 17.5.2.1.3 [bitmask.types] p.3 say that all elements on a bitmask type have distinct values, but 28.5.2 [re.matchflag] defines regex_constants::match_default and regex_constants::format_default as elements of the bitmask type regex_constants::match_flag_type, both with value 0. This is a contradiction.

[ Resolution proposed by ballot comment: ]

One of the bitmask elements should be removed from the declaration and should be defined separately, in the same manner as ios_base::adjustfield, ios_base::basefield and ios_base::floatfield are defined by 27.5.2.1.2 [ios::fmtflags] p.2 and Table 120. These are constants of a bitmask type, but are not distinct elements, they have more than one value set in the bitmask. regex_constants::format_default should be specified as a constant with the same value as regex_constants::match_default.

[ 2010-10-31 Daniel comments: ]

Strictly speaking, a bitmask type cannot have any element of value 0 at all, because any such value would contradict the requirement expressed in 17.5.2.1.3 [bitmask.types] p. 3:

for any pair Ci and Cj, Ci & Ci is nonzero
So, actually both regex_constants::match_default and regex_constants::format_default are only constants of the type regex_constants::match_flag_type, and no bitmask elements.

[ 2010-11-03 Daniel comments and provides a proposed resolution: ]

The proposed resolution is written against N3126 and considered as a further improvement of the fixes suggested by n3110.

Proposed resolution:

Add the following sentence to 28.5.2 [re.matchflag] paragraph 1:
1 The type regex_constants::match_flag_type is an implementation-defined bitmask type (17.5.2.1.3). Matching a regular expression against a sequence of characters [first,last) proceeds according to the rules of the grammar specified for the regular expression object, modified according to the effects listed in Table 136 for any bitmask elements set. Type regex_constants::match_flag_type also defines the constants regex_constants::match_default and regex_constants::format_default.

1452. [FCD] "target sequence" is not defined

Section: 28.10.4 [re.results.acc] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-01

View all other issues in [re.results.acc].

View all issues with Open status.

Discussion:

Addresses GB-125

The term "target sequence" is not defined (28.10.4 [re.results.acc] p. 2).

[ Resolution proposed by ballot comment: ]

Replace "target sequence" with "string being searched/matched"

[ 2010-11-01 Daniel comments: ]

The proposed resolution looks incomplete to me, there are more normative usages of the term target sequence in clause 28, e.g. 28.12.2 [re.tokiter] p. 7.

Proposed resolution:

Wording changes are against N3126. They are intended not to conflict with the wording changes suggested by n3158.

Change 28.10.4 [re.results.acc] p. 2 as indicated:

difference_type position(size_type sub = 0) const;
2 Returns: The distance from the start of the target sequencestring being matched to (*this)[sub].first.

1456. [FCD] Missing fixed-size atomic_ typedefs

Section: 29 [atomics] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-29

View other active issues in [atomics].

View all other issues in [atomics].

View all issues with Open status.

Discussion:

Addresses GB-129

Table 143 lists the typedefs for various atomic types corresponding to the various standard integer typedefs, such as atomic_int_least8_t for int_least8_t, and atomic_uint_fast64_t for uint_fast64_t. However, there are no atomic typedefs corresponding to the fixed-size standard typedefs int8_t, int16_t, and so forth.

[ 2010-10-24 Daniel adds: ]

Accepting n3164 would solve this issue.

Proposed resolution:

Add the following entries to table 143:
Table 143 — Atomics for standard typedef types
atomic typedef name <cstdint> typedef name
... ...
atomic_uintmax_t uintmax_t
atomic_int8_t int8_t (optional)
atomic_int16_t int16_t (optional)
atomic_int32_t int32_t (optional)
atomic_int64_t int64_t (optional)
atomic_uint8_t uint8_t (optional)
atomic_uint16_t uint16_t (optional)
atomic_uint32_t uint32_t (optional)
atomic_uint64_t uint64_t (optional)

1457. [FCD] Splitting lock-free properties

Section: 29.2 [atomics.syn] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-26

View all issues with Open status.

Discussion:

Addresses GB-130

The synopsis for the <atomic> header lists the macros ATOMIC_INTEGRAL_LOCK_FREE and ATOMIC_ADDRESS_LOCK_FREE.

The ATOMIC_INTEGRAL_LOCK_FREE macro has been replaced with a set of macros for each integral type, as listed in 29.4 [atomics.lockfree].

[ 2010-10-26: Daniel adds: ]

The proposed resolution below is against the FCD working draft. After application of the editorial issues US-144 and US-146 the remaining difference against the working draft is the usage of implementation-defined instead of unspecified, effectively resulting in this delta:

// 29.4, lock-free property
#define ATOMIC_CHAR_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_CHAR16_T_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_CHAR32_T_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_WCHAR_T_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_SHORT_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_INT_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_LONG_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_LLONG_LOCK_FREE unspecifiedimplementation-defined
#define ATOMIC_ADDRESS_LOCK_FREE unspecified

It is my understanding that the intended wording should be unspecified as for ATOMIC_ADDRESS_LOCK_FREE but if this is right, we need to use the same wording in 29.4 [atomics.lockfree], which consequently uses the term implementation-defined. I recommend to keep 29.2 [atomics.syn] as it currently is and to fix 29.4 [atomics.lockfree] instead as indicated (against N3126):

New proposed resolution:

Change 29.4 [atomics.lockfree] as indicated:

#define ATOMIC_CHAR_LOCK_FREE implementation-definedunspecified
#define ATOMIC_CHAR16_T_LOCK_FREE implementation-definedunspecified
#define ATOMIC_CHAR32_T_LOCK_FREE implementation-definedunspecified
#define ATOMIC_WCHAR_T_LOCK_FREE implementation-definedunspecified
#define ATOMIC_SHORT_LOCK_FREE implementation-definedunspecified
#define ATOMIC_INT_LOCK_FREE implementation-definedunspecified
#define ATOMIC_LONG_LOCK_FREE implementation-definedunspecified
#define ATOMIC_LLONG_LOCK_FREE implementation-definedunspecified
#define ATOMIC_ADDRESS_LOCK_FREE implementation-definedunspecified

Proposed resolution:

Against FCD, N3092:

In [atomics.syn], header <atomic> synopsis replace as indicated:

// 29.4, lock-free property
#define ATOMIC_INTEGRAL_LOCK_FREE unspecified
#define ATOMIC_CHAR_LOCK_FREE implementation-defined
#define ATOMIC_CHAR16_T_LOCK_FREE implementation-defined
#define ATOMIC_CHAR32_T_LOCK_FREE implementation-defined
#define ATOMIC_WCHAR_T_LOCK_FREE implementation-defined
#define ATOMIC_SHORT_LOCK_FREE implementation-defined
#define ATOMIC_INT_LOCK_FREE implementation-defined
#define ATOMIC_LONG_LOCK_FREE implementation-defined
#define ATOMIC_LLONG_LOCK_FREE implementation-defined
#define ATOMIC_ADDRESS_LOCK_FREE unspecified

1459. [FCD] Overlapping evaluations are allowed

Section: 29.3 [atomics.order] Status: Open Submitter: Canada Opened: 2010-08-25 Last modified: 2010-10-29

View all other issues in [atomics.order].

View all issues with Open status.

Duplicate of: 1458

Discussion:

Addresses CA-21, GB-131

29.4 [atomics.lockfree] p.8 states:

An atomic store shall only store a value that has been computed from constants and program input values by a finite sequence of program evaluations, such that each evaluation observes the values of variables as computed by the last prior assignment in the sequence.

... but 1.9 [intro.execution] p.13 states:

If A is not sequenced before B and B is not sequenced before A, then A and B are unsequenced. [ Note: The execution of unsequenced evaluations can overlap. — end note ]

Overlapping executions can make it impossible to construct the sequence described in 29.4 [atomics.lockfree] p.8. We are not sure of the intention here and do not offer a suggestion for change, but note that 29.4 [atomics.lockfree] p.8 is the condition that prevents out-of-thin-air reads.

For an example, suppose we have a function invocation f(e1,e2). The evaluations of e1 and e2 can overlap. Suppose that the evaluation of e1 writes y and reads x whereas the evaluation of e2 reads y and writes x, with reads-from edges as below (all this is within a single thread).

 e1           e2
Wrlx y--   --Wrlx x
      rf\ /rf
         X
        / \
Rrlx x<-   ->Rrlx y
This seems like it should be allowed, but there seems to be no way to produce a sequence of evaluations with the property above.

In more detail, here the two evaluations, e1 and e2, are being executed as the arguments of a function and are consequently not sequenced-before each other. In practice we'd expect that they could overlap (as allowed by 1.9 [intro.execution] p.13), with the two writes taking effect before the two reads. However, if we have to construct a linear order of evaluations, as in 29.4 [atomics.lockfree] p.8, then the execution above is not permited. Is that really intended?

[ Resolution proposed by ballot comment ]

Please clarify.

Proposed resolution:


1460. [FCD] Missing lock-free property for type bool should be added

Section: 29.4 [atomics.lockfree] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View all other issues in [atomics.lockfree].

View all issues with Open status.

Discussion:

Addresses US-154

There is no ATOMIC_BOOL_LOCK_FREE macro.

Proposed resolution:

Add ATOMIC_BOOL_LOCK_FREE to 29.4 [atomics.lockfree] and to 29.2 [atomics.syn]:

[..]
#define ATOMIC_BOOL_LOCK_FREE unspecified
#define ATOMIC_CHAR_LOCK_FREE unspecified
#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
[..]


1461. [FCD] Rename all ATOMIC_* macros as STD_ATOMIC_*

Section: 29 [atomics] Status: Open Submitter: Canada Opened: 2010-08-25 Last modified: 2010-10-26

View other active issues in [atomics].

View all other issues in [atomics].

View all issues with Open status.

Discussion:

Addresses CA-1

All ATOMIC_... macros should be prefixed with STD_ as in STD_ATOMIC_... to indicate they are STD macros as other standard macros. The rationale that they all seem too long seems weak.

Proposed resolution:

  1. Change sub-clause 29.2 [atomics.syn] as indicated:

    [..]
    // 29.4, lock-free property
    #define STD_ATOMIC_CHAR_LOCK_FREE unspecified
    #define STD_ATOMIC_CHAR16_T_LOCK_FREE unspecified
    #define STD_ATOMIC_CHAR32_T_LOCK_FREE unspecified
    #define STD_ATOMIC_WCHAR_T_LOCK_FREE unspecified
    #define STD_ATOMIC_SHORT_LOCK_FREE unspecified
    #define STD_ATOMIC_INT_LOCK_FREE unspecified
    #define STD_ATOMIC_LONG_LOCK_FREE unspecified
    #define STD_ATOMIC_LLONG_LOCK_FREE unspecified
    #define STD_ATOMIC_ADDRESS_LOCK_FREE unspecified
    
    // 29.6, operations on atomic types
    #define STD_ATOMIC_VAR_INIT(value) see below
    [..]
    

  2. Change 29.4 [atomics.lockfree] p. 1 as indicated:
    #define STD_ATOMIC_CHAR_LOCK_FREE implementation-defined
    #define STD_ATOMIC_CHAR16_T_LOCK_FREE implementation-defined
    #define STD_ATOMIC_CHAR32_T_LOCK_FREE implementation-defined
    #define STD_ATOMIC_WCHAR_T_LOCK_FREE implementation-defined
    #define STD_ATOMIC_SHORT_LOCK_FREE implementation-defined
    #define STD_ATOMIC_INT_LOCK_FREE implementation-defined
    #define STD_ATOMIC_LONG_LOCK_FREE implementation-defined
    #define STD_ATOMIC_LLONG_LOCK_FREE implementation-defined
    #define STD_ATOMIC_ADDRESS_LOCK_FREE implementation-defined
    
    1 The STD_ATOMIC_..._LOCK_FREE macros indicate the lock-free property of the corresponding atomic types, [..]
  3. Change 29.6 [atomics.types.operations] p. 5 as indicated:
    #define STD_ATOMIC_VAR_INIT(value) see below
    
    5 Remarks: A macro that expands to a token sequence suitable for initializing an atomic variable of a type that is initializion-compatible with value. Concurrent access to the variable being initialized, even via an atomic operation, constitutes a data race. [ Example:
    atomic_int v = STD_ATOMIC_VAR_INIT(5);
    
    end example ]
  4. Change 29.7 [atomics.flag] p. 1+4 as indicated:
    namespace std {
      [..]
      #define STD_ATOMIC_FLAG_INIT see below
    }
    
    [..] 4 The macro STD_ATOMIC_FLAG_INIT shall be defined in such a way that it can be used to initialize an object of type atomic_flag to the clear state. For a static-duration object, that initialization shall be static. It is unspecified whether an unitialized atomic_flag object has an initial state of set or clear. [ Example:
    atomic_flag guard = STD_ATOMIC_FLAG_INIT;
    
    end example ]

1474. [FCD] weak compare-and-exchange confusion

Section: 29.6 [atomics.types.operations] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [atomics.types.operations].

View all other issues in [atomics.types.operations].

View all issues with Open status.

Duplicate of: 1470, 1475, 1476, 1477

Discussion:

Addresses US-175, US-165, CH-23, GB-135

29.6 [atomics.types.operations] p. 23: The first sentence is grammatically incorrect.

[ 2010-10-28 Daniel adds: ]

Proposed resolution of duplicate issue 1475:

Change 29.6 [atomics.types.operations] p. 23 as indicated:
23 Remark: The weak compare-and-exchange operations may fail spuriously, that is, return false while leaving the contents of memory pointed to by expected before the operation is the same that same as that of the object and the same as that of expected after the operationThe weak compare-and-exchange operations may fail spuriously, that is, return false while leaving the contents of memory pointed to by expected unchanged.. [ Note: This spurious failure enables implementation of compare-and-exchange on a broader class of machines, e.g., loadlocked store-conditional machines. A consequence of spurious failure is that nearly all uses of weak compare-and-exchange will be in a loop.

When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable. — end note ]

Proposed resolution:

Change 29.6 [atomics.types.operations] p. 23 as indicated:
23 Remark: The weak compare-and-exchange operations may fail spuriously, that is, return false while leaving the contents of memory pointed to by expected before the operation is the same that same as that of the object and the same as that of expected after the operationThe weak compare-and-exchange operations may fail spuriously. That is, it may return false while leaving the contents of memory pointed to by expected the same as it was before the operation. [ Note: This spurious failure enables implementation of compare-and-exchange on a broader class of machines, e.g., loadlocked store-conditional machines. A consequence of spurious failure is that nearly all uses of weak compare-and-exchange will be in a loop.

When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable. — end note ]


1478. [FCD] Clarify race conditions in atomics initialization

Section: 29.6 [atomics.types.operations] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2010-10-29

View other active issues in [atomics.types.operations].

View all other issues in [atomics.types.operations].

View all issues with Open status.

Discussion:

Addresses GB-136

GB requests normative clarification in 29.6 [atomics.types.operations] p.4 that concurrent access constitutes a race, as already done on p.6 and p.7.

[ Resolution proposed in ballot comment: ]

Initialisation of atomics:

We believe the intent is that for any atomics there is a distinguished initialisation write, but that this need not happens-before all the other operations on that atomic - specifically so that the initialisation write might be non-atomic and hence give rise to a data race, and hence undefined behaviour, in examples such as this (from Hans):

atomic<atomic<int> *> p
f()                      |
{ atomic<int>x;          | W_na x
  p.store(&x,mo_rlx); | W_rlx p=&x
}                        |
(where na is nonatomic and rlx is relaxed). We suspect also that no other mixed atomic/nonatomic access to the same location is intended to be permitted. Either way, a note would probably help.

Proposed resolution:


1479. [FCD] Fence functions should be extern "C"

Section: 29.8 [atomics.fences] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [atomics.fences].

View all other issues in [atomics.fences].

View all issues with Open status.

Discussion:

Addresses US-179

The fence functions (29.8 [atomics.fences] p.5 + p.6) should be extern "C", for C compatibility.

Proposed resolution:

  1. Change 29.2 [atomics.syn], header <atomic> synopsis as indicated:
    namespace std {
      [..]
      // 29.8, fences
      extern "C" void atomic_thread_fence(memory_order);
      extern "C" void atomic_signal_fence(memory_order);  
    }
    
  2. Change 29.8 [atomics.fences], p. 5 and p. 6 as indicated:
    extern "C" void atomic_thread_fence(memory_order);
    
    5 Effects: depending on the value of order, this operation: [..]
    extern "C" void atomic_signal_fence(memory_order);  
    
    6 Effects: equivalent to atomic_thread_fence(order), except that synchronizes with relationships are established only between a thread and a signal handler executed in the same thread.

1480. [FCD] Atomic fences don't have synchronizes with relation

Section: 29.8 [atomics.fences] Status: Review Submitter: BSI Opened: 2010-08-25 Last modified: 2010-11-14

View other active issues in [atomics.fences].

View all other issues in [atomics.fences].

View all issues with Review status.

Discussion:

Addresses GB-137

Thread fence not only establish synchronizes with relationships, there are semantics of fences that are expressed not in terms of synchronizes with relationships (for example see 29.3 [atomics.order] p.5). These semantics also need to apply to the use of atomic_signal_fence in a restricted way.

[Batavia: Concurrency group discussed issue, and is OK with the proposed resolution.]

Proposed resolution:

Change 29.8 [atomics.fences] p. 6 as indicated:
void atomic_signal_fence(memory_order);  
6 Effects: equivalent to atomic_thread_fence(order), except that synchronizes with relationshipsthe resulting ordering constraints are established only between a thread and a signal handler executed in the same thread.

1485. [FCD] Unclear thread::id specification

Section: 30.3.1.1 [thread.thread.id] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-23

View all other issues in [thread.thread.id].

View all issues with Open status.

Discussion:

Addresses US-184

It is unclear when a thread::id ceases to be meaningful. The sentence "The library may reuse the value of a thread::id of a terminated thread that can no longer be joined." implies that some terminated threads can be joined. It says nothing about detached threads.

[ Resolution proposed by ballot comment: ]

Require a unique thread::id for every thread that is (1) detached and not terminated or (2) has an associated std::thread object.

[ 2010-11-22 Howard Hinnant observes ]

A thread can either be running or terminated. Additionally a thread can be joined, detached, or neither. These combine into the five possible states shown in this table:

RunningTerminated
Neither joined nor detachedshall not reuse idshall not reuse id
detachedshall not reuse idmay reuse id
joinedimpossible statemay reuse id

Only if a thread is neither joined nor detached can it be joined. Or said differently, if a thread has already been joined or detached, then it can not be joined. The sentence:

The library may reuse the value of a thread::id of a terminated thread that can no longer be joined.
precisely defines the two states shown in the above table where a thread::id may be reused.

The following program illustrates all of the possibilities:

#include <mutex>
#include <thread>
#include <iostream>
#include <chrono>

std::mutex mut;

void f()
{
   std::lock_guard<std::mutex> _(mut);
   std::cout << "f id = " << std::this_thread::get_id() << " terminating\n";
}

void g()
{
   std::lock_guard<std::mutex> _(mut);
   std::cout << "g id = " << std::this_thread::get_id() << " terminating\n";
}

int main()
{
   std::cout << "main id = " << std::this_thread::get_id() << "\n";
   std::thread t1(f);
   std::thread(g).detach();
   std::this_thread::sleep_for(std::chrono::seconds(1));
   std::cout << "g's thread::id can be reused here because g has terminated and is detached.\n";
   std::cout << "f's thread::id can't be reused here because f has terminated but is still joinable.\n";
   std::cout << "f id = " << t1.get_id() << "\n";
   t1.join();
   std::cout << "f's thread::id can be reused here because f has terminated and is joined.\n";
   std::cout << "f id = " << t1.get_id() << "\n";
}

main id = 0x7fff71197ca0
f id = 0x100381000 terminating
g id = 0x100581000 terminating
g's thread::id can be reused here because g has terminated and is detached.
f's thread::id can't be reused here because f has terminated but is still joinable.
f id = 0x100381000
f's thread::id can be reused here because f has terminated and is joined.
f id = 0x0

Proposed resolution:


1486. [FCD] Value of this_thread::get_id() underspecified for detached thread

Section: 30.3.2 [thread.thread.this] Status: Open Submitter: Switzerland Opened: 2010-08-25 Last modified: 2010-11-23

View other active issues in [thread.thread.this].

View all other issues in [thread.thread.this].

View all issues with Open status.

Discussion:

Addresses CH-24

What would be the value this_thread::get_id() when called from a detached thread?

[ Resolution proposed by ballot comment: ]

Add some text to clarify that get_id() still returns the same value even after detaching.

[ 2010-11-22 Howard Hinnant observes ]

30.3.2 [thread.thread.this]/1 contains the following sentence describing this_thread::get_id():

... No other thread of execution shall have this id and this thread of execution shall always have this id.
I don't object to adding "even if detached" to this sentence, but it seems unnecessary to me. "Always" means always.

Proposed resolution:


1487. [FCD] Clock related operations exception specifications conflict

Section: 30.3.2 [thread.thread.this] Status: Open Submitter: Switzerland Opened: 2010-08-25 Last modified: 2010-11-01

View other active issues in [thread.thread.this].

View all other issues in [thread.thread.this].

View all issues with Open status.

Discussion:

Addresses CH-25

Clock related operations are currently not required not to throw. So "Throws: Nothing." is not always true.

[ Resolution proposed by ballot comment: ]

Either require clock related operations not to throw (in 20.10) or change the Throws clauses in 30.3.2. Also possibly add a note that abs_time in the past or negative rel_time is allowed.

Proposed resolution:


1494. [FCD] Term "are serialized" not defined

Section: 30.4.4.2 [thread.once.callonce] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View all issues with Open status.

Discussion:

Addresses US-190

The term "are serialized" is never defined (30.4.4.2 [thread.once.callonce] p. 2).

[ Resolution proposed by ballot comment: ]

Remove the sentence with "are serialized" from paragraph 2. Add "Calls to call_once on the same once_flag object shall not introduce data races (17.6.4.8)." to paragraph 3.

[ 2010-11-01 Daniel translates NB comment into wording ]

Proposed resolution:

Change 30.4.4.2 [thread.once.callonce] p.2+3 as indicated:
template<class Callable, class ...Args>
void call_once(once_flag& flag, Callable&& func, Args&&... args);
[..]

2 Effects: Calls to call_once on the same once_flag object are serialized. If there has been a prior effective call to call_once on the same once_flag object, the call to call_once returns without invoking func. If there has been no prior effective call to call_once on the same once_flag object, INVOKE(decay_copy( std::forward<Callable>(func)), decay_copy(std::forward<Args>(args))...) is executed. The call to call_once is effective if and only if INVOKE(decay_copy( std::forward<Callable>(func)), decay_copy(std::forward<Args>(args))...) returns without throwing an exception. If an exception is thrown it is propagated to the caller.

3 Synchronization: The completion of an effective call to call_once on a once_flag object synchronizes with (1.10) all subsequent calls to call_once on the same once_flag object. Calls to call_once on the same once_flag object shall not introduce data races ([res.on.data.races]).


1497. [FCD] lock() postcondition can not be generally achieved

Section: 30.5 [thread.condition] Status: Tentatively Ready Submitter: Switzerland Opened: 2010-08-25 Last modified: 2010-11-08

View all other issues in [thread.condition].

View all issues with Tentatively Ready status.

Discussion:

Addresses CH-30

If lock.lock() throws an exception, the postcondition can not be generally achieved.

[ Resolution proposed by ballot comment: ]

Either state that the postcondition might not be achieved, depending on the error condition, or state that terminate() is called in this case.

[ 2010-08-13 Peter Sommerlad comments and provides wording ]

30.5.1 [thread.condition.condvar], 30.5.2 [thread.condition.condvarany]

p. 13, last bullet, and corresponding paragraphs in all wait functions

Problem:
Condition variable wait might fail, because the lock cannot be acquired when notified. CH-30 says: "If lock.lock() throws an exception, the postcondition can not be generally achieved." CH-30 proposes: "Either state that the postcondition might not be achieved, depending on the error condition, or state that terminate() is called in this case."

The discussion in Rapperswil concluded that calling terminate() might be too drastic in this case and a corresponding exception should be thrown/passed on and one should use a lock type that allows querying its status, which unique_lock allows for std::condition_variable

We also had some additional observations while discussing in Rapperswil:

and add the following proposed solution:

Proposed resolution:

  1. Change 30.5.1 [thread.condition.condvar] as indicated:
    void wait(unique_lock<mutex>& lock);
    
    12 Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either
    • no other thread is waiting on this condition_variable object or
    • lock.mutex() returns the same value for each of the lock arguments supplied by all concurrently waiting (via wait or timed_wait) threads.
    [..]
    14 Postcondition: lock.owns_lock() is true and lock.mutex() is locked by the calling thread.
    [..]
    template <class Predicate>
    void wait(unique_lock<mutex>& lock, Predicate pred);
    
    ?? Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either
    • no other thread is waiting on this condition_variable object or
    • lock.mutex() returns the same value for each of the lock arguments supplied by all concurrently waiting (via wait or timed_wait) threads.
    17 Effects:
    while (!pred())
      wait(lock);
    
    ?? Postcondition: lock.owns_lock() is true and lock.mutex() is locked by the calling thread.
    ?? Throws: std::system_error when an exception is required (30.2.2).
    ?? Error conditions:
    • equivalent error condition from lock.lock() or lock.unlock().
    template <class Clock, class Duration>
    cv_status wait_until(unique_lock<mutex>& lock,
      const chrono::time_point<Clock, Duration>& abs_time);
    
    18 Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either
    • no other thread is waiting on this condition_variable object or
    • lock.mutex() returns the same value for each of the lock arguments supplied by all concurrently waiting (via wait, wait_for, or wait_until) threads.
    [..]
    20 Postcondition: lock.owns_lock() is true and lock.mutex() is locked by the calling thread.
    [..]
    23 Error conditions:
    • operation_not_permitted — if the thread does not own the lock.
    • equivalent error condition from lock.lock() or lock.unlock().
    template <class Rep, class Period>
    cv_status wait_for(unique_lock<mutex>& lock,
      const chrono::duration<Rep, Period>& rel_time);
    
    24 Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either
    • no other thread is waiting on this condition_variable object or
    • lock.mutex() returns the same value for each of the lock arguments supplied by all concurrently waiting (via wait, wait_for, or wait_until) threads.
    [..]
    27 Postcondition: lock.owns_lock() is true and lock.mutex() is locked by the calling thread.
    [..]
    29 Error conditions:
    • operation_not_permitted — if the thread does not own the lock.
    • equivalent error condition from lock.lock() or lock.unlock().
    template <class Clock, class Duration, class Predicate>
    bool wait_until(unique_lock<mutex>& lock,
      const chrono::time_point<Clock, Duration>& abs_time,
        Predicate pred);
    
    ?? Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either
    • no other thread is waiting on this condition_variable object or
    • lock.mutex() returns the same value for each of the lock arguments supplied by all concurrently waiting (via wait or timed_wait) threads.
    30 Effects:
    while (!pred())
      if (wait_until(lock, abs_time) == cv_status::timeout)
        return pred();
    return true;
    
    31 Returns: pred()
    ?? Postcondition: lock.owns_lock() is true and lock.mutex() is locked by the calling thread.
    32 [ Note: The returned value indicates whether the predicate evaluates to true regardless of whether the timeout was triggered. — end note ]
    ?? Throws: std::system_error when an exception is required (30.2.2).
    ?? Error conditions:
    • equivalent error condition from lock.lock() or lock.unlock().
    template <class Rep, class Period, class Predicate>
    bool wait_for(unique_lock<mutex>& lock,
      const chrono::duration<Rep, Period>& rel_time,
        Predicate pred);
    
    33 Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either
    • no other thread is waiting on this condition_variable object or
    • lock.mutex() returns the same value for each of the lock arguments supplied by all concurrently waiting (via wait, wait_for, or wait_until) threads.
    [..]
    36 Postcondition: lock.owns_lock() is true and lock.mutex() is locked by the calling thread.
    [..]
    40 Error conditions:
    • operation_not_permitted — if the thread does not own the lock.
    • equivalent error condition from lock.lock() or lock.unlock().
  2. Change 30.5.2 [thread.condition.condvarany] as indicated:

    [..]

    template <class Lock, class Predicate>
    void wait(Lock& lock, Predicate pred);
    
    [Note: if any of the wait functions exits with an exception it is indeterminate if the Lock is held. One can use a Lock type that allows to query that, such as the unique_lock wrapper. — end note]
    14 Effects:
    while (!pred())
      wait(lock);
    
    [..]
    34 Error conditions:
    • operation_not_permitted — if the thread does not own the lock.
    • equivalent error condition from lock.lock() or lock.unlock().

1502. [FCD] Specification of [futures.state]

Section: 30.6.4 [futures.state] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [futures.state].

View all other issues in [futures.state].

View all issues with Open status.

Discussion:

Addresses US-195

The intent and meaning of the paragraph is not apparent.

Proposed resolution:


1503. [FCD] "associated asynchronous state" must go

Section: 30.6.4 [futures.state] Status: Open Submitter: Switzerland Opened: 2010-08-25 Last modified: 2010-11-01

View other active issues in [futures.state].

View all other issues in [futures.state].

View all issues with Open status.

Discussion:

Addresses CH-35

The term "associated asynchronous state" is long, ugly and misleading terminology. When introduced we agreed upon that we should come up with a better name. Here it is: "liaison state". Since the state is hidden and provides synchronization of a future with its corresponding promise, we believe "liaison state" is a much better and shorter name (liaison ~ (typically hidden) relationship)

[ Resolution proposed by ballot comment: ]

Change all occurrences of "associated asynchronous state" to "liaison state".

Proposed resolution:


1504. [FCD] Term "are serialized" is not defined

Section: 30.6.5 [futures.promise] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [futures.promise].

View all other issues in [futures.promise].

View all issues with Open status.

Discussion:

Addresses US-196

The term "are serialized" is not defined (30.6.5 [futures.promise] p. 21, 25).

[ Resolution proposed by ballot comment: ]

Replace "are serialized" with "shall not introduce a data race (17.6.4.8)".

[ 2010-11-02 Daniel translates proposal into proper wording changes ]

Proposed resolution:

  1. Change 30.6.5 [futures.promise] p. 21 as indicated:
    21 Synchronization: calls to set_value and set_exception on a single promise object are serializedshall not introduce a data race ([res.on.data.races]). [ Note: and they synchronize and serialize with other functions through the referred associated asynchronous state. — end note ]
  2. Change 30.6.5 [futures.promise] p. 25 as indicated:
    25 Synchronization: calls to set_value and set_exception on a single promise object are serializedshall not introduce a data race ([res.on.data.races]). [ Note: and they synchronize and serialize with other functions through the referred associated asynchronous state. — end note ]

1505. [FCD] Synchronization between promise::set_value and future::get

Section: 30.6.5 [futures.promise] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [futures.promise].

View all other issues in [futures.promise].

View all issues with Open status.

Discussion:

Addresses US-197

There is no defined synchronization between promise::set_value and future::get (30.6.5 [futures.promise] p. 21, 25).

[ Resolution proposed by ballot comment: ]

Replace "[Note: and they synchronize and serialize with other functions through the referred associated asynchronous state. --end note]" with the normative "They synchronize with (1.10) any operation on a future object with the same associated asynchronous state marked ready."

[ 2010-11-02 Daniel translates proposal into proper wording changes ]

Proposed resolution:

  1. Change 30.6.5 [futures.promise] p. 21 as indicated:
    21 Synchronization: calls to set_value and set_exception on a single promise object are serialized. [ Note: and they synchronize and serialize with other functions through the referred associated asynchronous state. — end note ]They synchronize with ([intro.multithread]) any operation on a future object with the same associated asynchronous state marked ready.
  2. Change 30.6.5 [futures.promise] p. 25 as indicated:
    25 Synchronization: calls to set_value and set_exception on a single promise object are serialized. [ Note: and they synchronize and serialize with other functions through the referred associated asynchronous state. — end note ]They synchronize with ([intro.multithread]) any operation on a future object with the same associated asynchronous state marked ready.

1507. [FCD] promise::XXX_at_thread_exit functions have no synchronization requirements

Section: 30.6.5 [futures.promise] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [futures.promise].

View all other issues in [futures.promise].

View all issues with Open status.

Discussion:

Addresses US-199

promise::XXX_at_thread_exit functions have no synchronization requirements. Specifying synchronization for these member functions requires coordinating with the words in 30.6.5/21 and 25, which give synchronization requirements for promise::set_value and promise::set_exception (30.6.5 [futures.promise] p. 26 ff., p. 29 ff.).

[ Resolution proposed by ballot comment: ]

Change 30.6.5/21 to mention set_value_at_thread_exit and set_exception_at_thread_exit; with this text, replace 30.6.5/25 and add two new paragraphs, after 30.6.5/28 and 30.6.5/31.

Proposed resolution:


1514. [FCD] packaged_task constructors need review

Section: 30.6.10.1 [futures.task.members] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [futures.task.members].

View all other issues in [futures.task.members].

View all issues with Open status.

Discussion:

Addresses US-207

The constructor that takes R(*)(ArgTypes...) is not needed; the constructor that takes a callable type works for this argument type. More generally, the constructors for packaged_task should parallel those for function.

[ US-207 Suggested Resolution: ]

Review the constructors for packaged_task and provide the same ones as function, except where inappropriate.

[ 2010-10-22 Howard provides wording, as requested by the LWG in Rapperswil. ]

Proposed resolution:

Alter the list of constructors in both [futures.task] and in [futures.task.members] as indicated:
template <class F>
explicit packaged_task(F f);
template <class F, class Allocator>
explicit packaged_task(allocator_arg_t, const Allocator& a, F f);
explicit packaged_task(R(*f)(ArgTypes...));
template <class F>
explicit packaged_task(F&& f);
template <class F, class Allocator>
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);

1515. [FCD] packaged_task::make_ready_at_thread_exit has no synchronization requirements

Section: 30.6.10.1 [futures.task.members] Status: Open Submitter: INCITS Opened: 2010-08-25 Last modified: 2010-11-04

View other active issues in [futures.task.members].

View all other issues in [futures.task.members].

View all issues with Open status.

Discussion:

Addresses US-208

packaged_task::make_ready_at_thread_exit has no synchronization requirements.

[ Resolution proposed by ballot comment: ]

Figure out what the synchronization requirements should be and write them.

Proposed resolution:


1521. Requirements on internal pointer representations in containers

Section: 23.2.1 [container.requirements.general] Status: New Submitter: Mike Spertus Opened: 2010-10-16 Last modified: 2010-11-04

View other active issues in [container.requirements.general].

View all other issues in [container.requirements.general].

View all issues with New status.

Discussion:

Addresses US-104, US-141

The standard doesn't say that containers should use abstract pointer types internally. Both Howard and Pablo agree that this is the intent. Further, it is necessary for containers to be stored, for example, in shared memory with an interprocess allocator (the type of scenario that allocators are intended to support).

In spite of the (possible) agreement on intent, it is necessary to make this explicit:

An implementations may like to store the result of dereferencing the pointer (which is a raw reference) as an optimization, but that prevents the data structure from being put in shared memory, etc. In fact, a container could store raw references to the allocator, which would be a little weird but conforming as long as it has one by-value copy. Furthermore, pointers to locales, ctypes, etc. may be there, which also prevents the data structure from being put in shared memory, so we should make explicit that a container does not store raw pointers or references at all.

[ Pre-batavia ]

This issue is being opened as part of the response to NB comments US-104/141. See paper N3171 in the pre-Batavia mailing.

Proposed resolution:

Add to the end of 23.2.1 [container.requirements.general] p. 8:

[..] In all container types defined in this Clause, the member get_allocator() returns a copy of the allocator used to construct the container or, if that allocator has been replaced, a copy of the most recent replacement. The container may not store internal objects whose types are of the form T * or T & except insofar as they are part of the item type or members.

1523. [FCD] noexcept for Clause 29

Section: 29 [atomics] Status: New Submitter: Hans Boehm Opened: 2010-11-13 Last modified: 2010-11-14

View other active issues in [atomics].

View all other issues in [atomics].

View all issues with New status.

Discussion:

Addresses GB-63 for Clause 29

Clause 29 does not specify noexcept for any of the atomic operations. It probably should, though that's not completely clear. In particular, atomics may want to throw in implementations that support transactional memory.

Proposed resolution:


2000. Missing definition of packaged_task specialization of uses_allocator

Section: 30.6.10.2 [futures.task.nonmembers] Status: Tentatively Ready Submitter: Howard Hinnant Opened: 2010-08-29 Last modified: 2010-11-13

View all issues with Tentatively Ready status.

Discussion:

[futures.task.nonmembers]/3 says:

   template <class R, class Alloc>
     struct uses_allocator<packaged_task<R>, Alloc>;
This is a declaration, but should be a definition.

Proposed resolution:

Change [futures.task.nonmembers]/3:

   template <class R, class Alloc>
     struct uses_allocator<packaged_task<R>, Alloc>;
        : true_type {};

2001. Class template basic_regex uses non existent string_type

Section: 28.8.3 [re.regex.assign] Status: Open Submitter: Volker Lukas Opened: 2010-10-21 Last modified: 2010-11-13

View all issues with Open status.

Discussion:

In working draft N3126, subclause 28.8.3 [re.regex.assign], paragraphs 12, 13 and 19, the name string_type is used. This is presumably a typedef for basic_string<value_type>, where value_type is the character type used by basic_regex. The basic_regex template however defines no such typedef, and neither does the <regex> header or the <initializer_list> header included by <regex>.

[ 2010-11-03 Daniel comments and suggests alternative wording: ]

The proposed resolution needs to use basic_string<charT> instead of basic_string<char>

Proposed Resolution:

Make the following changes to [re.regex.assign]:

basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
12 Returns: assign(string_typebasic_string<charT>(ptr), f).
basic_regex& assign(const charT* ptr, size_t len,
  flag_type f = regex_constants::ECMAScript);
13 Returns: assign(string_typebasic_string<charT>(ptr, len), f).
[..]

template <class InputIterator> 
  basic_regex& assign(InputIterator first, InputIterator last, 
                          flag_type f = regex_constants::ECMAScript);
18 Requires: The type InputIterator shall satisfy the requirements for an Input Iterator (24.2.3).
19 Returns: assign(string_typebasic_string<charT>(first, last), f).

[ 2010 Batavia ]

Unsure if we should just give basic_regex a string_type typedef. Looking for when string_type was introduced into regex. Howard to draft wording for typedef typename traits::string_type string_type, then move to Review.

Proposed resolution:

Make the following changes to [re.regex.assign]:

basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
12 Returns: assign(string_typebasic_string<char>(ptr), f).
basic_regex& assign(const charT* ptr, size_t len,
  flag_type f = regex_constants::ECMAScript);
13 Returns: assign(string_typebasic_string<char>(ptr, len), f).
[..]

template <class InputIterator> 
  basic_regex& assign(InputIterator first, InputIterator last, 
                          flag_type f = regex_constants::ECMAScript);
18 Requires: The type InputIterator shall satisfy the requirements for an Input Iterator (24.2.3).
19 Returns: assign(string_typebasic_string<char>(first, last), f).

2003. String exception inconsistency in erase.

Section: 21.4.1 [string.require] Status: Open Submitter: José Daniel García Sánchez Opened: 2010-10-21 Last modified: 2010-11-13

View all other issues in [string.require].

View all issues with Open status.

Discussion:

Clause 21.4.1 [string.require]p3 states:

No erase() or pop_back() member function shall throw any exceptions.

However in 21.4.6.5 [string::erase] p2 the first version of erase has

Throws: out_of_range if pos > size().

Proposed resolution:

Update [string.require]p/3:

3 No erase() or pop_back() member function shall throw any exceptions.

2004. duration::operator* has template parameters in funny order

Section: 20.11.3.5 [time.duration.nonmember] Status: Tentatively Ready Submitter: P.J. Plauger Opened: 2010-10-14 Last modified: 2010-11-13

View all other issues in [time.duration.nonmember].

View all issues with Tentatively Ready status.

Discussion:

In [time] and [time.duration.nonmember] we have:

template <class Rep1, class Period, class Rep2>
    duration<typename common_type<Rep1, Rep2>::type, Period>
        operator*(const Rep1& s, const duration<Rep2, Period>& d);

Everywhere else, we always have <rep, period> in that order for a given type. But here, we have Period and Rep2 in reverse order for <Rep2, Period>. This is probably of little importance, since the template parameters are seldom spelled out for a function like this. But changing it now will eliminate a potential source of future errors and confusion.

Proposed resolution:

Change the signature in [time] and [time.duration.nonmember] to:

template <class Rep1, class PeriodRep2, class Rep2Period>
    duration<typename common_type<Rep1, Rep2>::type, Period>
        operator*(const Rep1& s, const duration<Rep2, Period>& d);

2005. unordered_map::insert(T&&) protection should apply to map too

Section: 23.6.1.3 [map.modifiers], 23.6.2.2 [multimap.modifiers] Status: Open Submitter: P.J. Plauger Opened: 2010-10-14 Last modified: 2010-11-13

View all issues with Open status.

Discussion:

In [unord.map.modifiers], the signature:

template <class P>
    pair<iterator, bool> insert(P&& obj);
now has an added Remarks paragraph:

Remarks: This signature shall not participate in overload resolution unless P is implicitly convertible to value_type.

The same is true for unordered_multimap.

But neither map nor multimap have this constraint, even though it is a Good Thing(TM) in those cases as well.

[ The submitter suggests: Add the same Remarks clause to [map.modifiers] and [multimap.modifiers]. ]

[ 2010-10-29 Daniel comments: ]

I believe both paragraphs need more cleanup: First, the current Requires element conflict with the Remark; second, it seems to me that the whole single Requires element is intended to be split into a Requires and an Effects element; third, the reference to tuple is incorrect (noticed by Paolo Carlini); fourth, it refers to some non-existing InputIterator parameter relevant for a completely different overload; sixth, the return type of the overload with hint is wrong. The following proposed resolution tries to solve these issues as well and uses similar wording as for the corresponding unordered containers. Unfortunately it has some redundancy over Table 99, but I did not remove the specification because of the more general template parameter P - the Table 99 requirements apply only for an argument identical to value_type.

Proposed resolution:

  1. Change 23.6.1.3 [map.modifiers] around p. 1 as indicated:
    template <class P> pair<iterator, bool> insert(P&& x);
    template <class P> pair<iterator, bool> insert(const_iterator position, P&& x);
    
    1 Requires: P shall be convertible to value_type is constructible from std::forward<P>(x)..

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type,mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.
    ? Effects: Inserts x converted to value_type if and only if there is no element in the container with key equivalent to the key of value_type(x). For the second form, the iterator position is a hint pointing to where the search should start.

    ? Returns: For the first form, the bool component of the returned pair object indicates whether the insertion took place and the iterator component - or for the second form the returned iterator - points to the element with key equivalent to the key of value_type(x).

    ? Complexity: Logarithmic in general, but amortized constant if x is inserted right before position.

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

  2. Change 23.6.2.2 [multimap.modifiers] around p. 1 as indicated:
    template <class P> iterator insert(P&& x);
    template <class P> iterator insert(const_iterator position, P&& x);
    
    1 Requires: P shall be convertible to value_type is constructible from std::forward<P>(x).

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type, mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.
    ? Effects: Inserts x converted to value_type. For the second form, the iterator position is a hint pointing to where the search should start.

    ? Returns: An iterator that points to the element with key equivalent to the key of value_type(x).

    ? Complexity: Logarithmic in general, but amortized constant if x is inserted right before position.

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

[ 2010 Batavia: ]

We need is_convertible, not is_constructible, both in ordered and unordered containers.

Proposed resolution:

  1. Add a new Remarks element after 23.6.1.3 [map.modifiers] p. 1:
    template <class P> pair<iterator, bool> insert(P&& x);
    template <class P> pair<iterator, bool> insert(const_iterator position, P&& x);
    
    1 Requires: P shall be convertible to value_type.

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type,mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

  2. Change 23.6.2.2 [multimap.modifiers] around p. 1 as indicated:
    template <class P> iterator insert(P&& x);
    template <class P> iterator insert(const_iterator position, P&& x);
    
    1 Requires: P shall be convertible to value_type.

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type, mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.


2006. emplace broken for associative containers

Section: 23.2.5 [unord.req] Status: Tentatively NAD Submitter: Pablo Halpern Opened: 2010-10-18 Last modified: 2010-11-13

View other active issues in [unord.req].

View all other issues in [unord.req].

View all issues with Tentatively NAD status.

Discussion:

The current definition of emplace(args) for associative containers as described in Table 99 is:

Requires: T shall be constructible from args.

Effects: Inserts a T object t constructed with std::forward<Args>(args)... if and only if there is no element in the container with key equivalent to the key of t. The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of t.

There is similar language in Table 100 for unordered associative containers.

The first issue is editorial: T should be value_type throughout both tables.

The major issue is that, if the container is map, multimap, unordered_map, or unordered_multimap, then the only way to construct an object of value_type is to supply exactly two arguments for Key and Value, a pair<Key,Value>, or a piecewise_construct_t followed by two tuples. The original emplace() proposal would have allowed you to specify a Key value followed by any number of constructor arguments for Value. When we removed the variadic constructor to pair, this ability went away. I don't think that was deliberate.

Fixing this is non-trivial, I think. I think that emplace() for map and multimap need several overloads: one for each overloaded constructor in pair<Key,Value>, and one for the emplace(Key, valueargs...) case. And it probably needs some SFINAE meta-programming to ensure that the last case doesn't override any of the other ones. Alternatively, one could say that there are exactly two cases: emplace(args) where pair<Key,Value> is constructible from args, and emplace(args) where Key is constructible form the first arg and Value is constructible from the rest.

Alternatively, the status quo is to use piecewise_construct_t if you want to construct an object.

[ 2010 Batavia: ]

N3178 was looked at in session and moved to NAD.

Proposed resolution:


2007. Incorrect specification of return value for map<>::at()

Section: 23.6.1.2 [map.access] Status: Tentatively Ready Submitter: Matt Austern Opened: 2010-11-01 Last modified: 2010-11-13

View all other issues in [map.access].

View all issues with Tentatively Ready status.

Discussion:

In [map.access]/9, the Returns clause for map<Key, T>::at(x) says that it returns "a reference to the element whose key is equivalent to x." That can't be right. The signature for at() says that its return type is T, but the elements of map<Key, T> have type pair<const K, T>. (I checked [unord.map.elem] and found that its specification of at() is correct. This is a problem for map only.)

Proposed resolution:

Change the wording in [map.access]/9 so it's identical to what we already say for operator[], which is unambiguous and correct.

Returns: A reference to the element whose key is equivalentmapped_type corresponding to x in *this.

2008. Conflicting Error Conditions for packaged_task::operator()

Section: 30.6.10.1 [futures.task.members] Status: New Submitter: Pete Becker Opened: 2010-06-21 Last modified: 2010-11-07

View other active issues in [futures.task.members].

View all other issues in [futures.task.members].

View all issues with New status.

Discussion:

The Throws clause for packaged_task::operator() says that it throws "a future_error exception object if there is no associated asynchronous state or the stored task has already been invoked." However, the Error Conditions clause does not define an error condition when the stored task has already been invoked, only when the associated state is already ready (i.e. the invocation has completed).

Proposed resolution:

Change the first bullet item in 30.6.10.1 [futures.task.members] /22:

void operator()(ArgTypes... args);

20 ...

21 ...

22 Error conditions:


2009. Reporting out-of-bound values on numeric string conversions

Section: 21.5 [string.conversions] Status: Review Submitter: Alisdair Meredith Opened: 2010-07-19 Last modified: 2010-11-13

View all other issues in [string.conversions].

View all issues with Review status.

Discussion:

The functions (w)stoi and (w)stof are specified in terms of calling C library APIs for potentially wider types. The integer and floating-point versions have subtly different behaviour when reading values that are too large to convert. The floating point case will throw out_of_bound if the read value is too large to convert to the wider type used in the implementation, but behaviour is undefined if the converted value cannot narrow to a float. The integer case will throw out_of_bounds if the converted value cannot be represented in the narrower type, but throws invalid_argument, rather than out_of_bounds, if the conversion to the wider type fails due to overflow.

Suggest that the Throws clause for both specifications should be consistent, supporting the same set of fail-modes with the matching set of exceptions.

Proposed resolution:

21.5p3 [string.conversions]

int stoi(const string& str, size_t *idx = 0, int base = 10);
long stol(const string& str, size_t *idx = 0, int base = 10);
unsigned long stoul(const string& str, size_t *idx = 0, int base = 10);
long long stoll(const string& str, size_t *idx = 0, int base = 10);
unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);

...

3 Throws: invalid_argument if strtol, strtoul, strtoll, or strtoull reports that no conversion could be performed. Throws out_of_range if strtol, strtoul, strtoll or strtoull sets errno to ERANGE, or if the converted value is outside the range of representable values for the return type.

21.5p6 [string.conversions]

float stof(const string& str, size_t *idx = 0);
double stod(const string& str, size_t *idx = 0);
long double stold(const string& str, size_t *idx = 0);

...

6 Throws: invalid_argument if strtod or strtold reports that no conversion could be performed. Throws out_of_range if strtod or strtold sets errno to ERANGE or if the converted value is outside the range of representable values for the return type.


2010. is_* traits for binding operations can't be meaningfully specialized

Section: 20.8.10.1.1 [func.bind.isbind] Status: Open Submitter: Sean Hunt Opened: 2010-07-19 Last modified: 2010-11-16

View all other issues in [func.bind.isbind].

View all issues with Open status.

Discussion:

20.8.10.1.1 [func.bind.isbind] says for is_bind_expression:

Users may specialize this template to indicate that a type should be treated as a subexpression in a bind call.

But it also says:

If T is a type returned from bind, is_bind_expression<T> shall be publicly derived from integral_constant<bool, true>, otherwise from integral_constant<bool, false>.

This means that while the user is free to specialize, any specialization would have to be false to avoid violating the second requirement. A similar problem exists for is_placeholder.

[ 2010 Batavia (post meeting session) ]

Alisdair recognises this is clearly a bug introduced by some wording he wrote, the sole purpose of this metafunction is as a customization point for users to write their own bind-expression types that participate in the standard library bind protocol. The consensus was that this should be fixed in Madrid, moved to Open.

Proposed resolution:


2011. unexpected output required of strings

Section: 21.4.8.9 [string.io] Status: Open Submitter: James Kanze Opened: 2010-07-23 Last modified: 2010-11-16

View all other issues in [string.io].

View all issues with Open status.

Discussion:

What should the following code output?

#include <string>
#include <iostream>
#include <iomanip>

int 
main() 
{ 
   std::string test("0X1Y2Z"); 
   std::cout.fill('*'); 
   std::cout.setf(std::ios::internal, std::ios::adjustfield); 
   std::cout << std::setw(8) << test << std::endl; 
} 

I would expect "**0X1Y2Z", and this is what the compilers I have access to (VC++, g++ and Sun CC) do. But according to the standard, it should be "0X**1Y2Z":

21.4.8.9 [string.io]/5:

template<class charT, class traits, class Allocator>
  basic_ostream<charT, traits>&
    operator<<(basic_ostream<charT, traits>& os, const basic_string<charT,traits,Allocator>& str);
Effects: Behaves as a formatted output function (27.7.2.6.1 [ostream.formatted.reqmts]). After constructing a sentry object, if this object returns true when converted to a value of type bool, determines padding as described in 22.4.2.2.2 [facet.num.put.virtuals], then inserts the resulting sequence of characters seq as if by calling os.rdbuf()->sputn(seq, n), where n is the larger of os.width() and str.size(); then calls os.width(0).

22.4.2.2.2 [facet.num.put.virtuals]/5:

[...]

Stage 3: A local variable is initialized as

fmtflags adjustfield= (flags & (ios_base::adjustfield));

The location of any padding is determined according to Table 88.

If str.width() is nonzero and the number of charT's in the sequence after stage 2 is less than str.width(), then enough fill characters are added to the sequence at the position indicated for padding to bring the length of the sequence to str.width(). str.width(0) is called.

Table 88 — Fill padding
State Location
adjustfield == ios_base::left pad after
adjustfield == ios_base::right pad before
adjustfield == internal and a sign occurs in the representation pad after the sign
adjustfield == internal and representation after stage 1 began with 0x or 0X pad after x or X
otherwise pad before

Although it's not 100% clear what "the sequence after stage 2" should mean here, when there is no stage 2, the only reasonable assumption is that it is the contents of the string being output. In the above code, the string being output is "0X1Y2Z", which starts with "0X", so the padding should be inserted "after x or X", and not before the string. I believe that this is a defect in the standard, and not in the three compilers I tried.

[ 2010 Batavia (post meeting session) ]

Consensus that all known implementations are consistent, and disagree with the standard. Preference is to fix the standard before implementations start trying to conform to the current spec, as the current implementations have the preferred form. Howard volunteered to drught for Madrid, move to Open.

Proposed resolution:


2012. Associative maps should insert pair, not tuple

Section: 23.6 [associative] Status: New Submitter: Paolo Carlini Opened: 2010-10-29 Last modified: 2010-11-07

View all other issues in [associative].

View all issues with New status.

Discussion:

I'm seeing something strange in the paragraphs 23.6.1.3 [map.modifiers] and 23.6.2.2 [multimap.modifiers]: they both talk about tuple<const key_type, mapped_type> but I think they should be talking about pair<const key_type, mapped_type> because, among other reasons, a tuple is not convertible to a pair. If I replace tuple with pair everything makes sense to me. The proposed resolution is obvious.

[ 2010-11-07 Daniel comments ]

This is by far not the only necessary fix within both sub-clauses. For details see the 2010-10-29 comment in 2005.

Proposed resolution:

Apply the resolution proposed by the 2010-10-29 comment in 2005.

2013. Do library implementers have the freedom to add constexpr?

Section: 17.6.4.6 [constexpr.functions] Status: New Submitter: Matt Austern Opened: 2010-11-12 Last modified: 2010-11-13

View all issues with New status.

Discussion:

Suppose that a particular function is not tagged as constexpr in the standard, but that, in some particular implementation, it is possible to write it within the constexpr constraints. If an implementer tags such a function as constexpr, is that a violation of the standard or is it a conforming extension?

There are two questions to consider. First, is this allowed under the as-if rule? Second, if it does not fall under as-if, is there (and should there be) any special license granted to implementers to do this anyway, sort of the way we allow elision of copy constructors even though it is detectable by users?

I believe that this does not fall under "as-if", so implementers probably don't have that freedom today. I suggest changing the WP to grant it. Even if we decide otherwise, however, I suggest that we make it explicit.

Proposed resolution:

In 17.6.4.6 [constexpr.functions], change paragraph 1 to:

This standard explicitly requires that certain standard library functions are constexpr [dcl.constexpr]. Additionally, an implementation may declare any function to be constexpr if that function's definition satisfies the necessary constraints. Within any header that provides any non-defining declarations of constexpr functions or constructors an implementation shall provide corresponding definitions.

2014. More restrictions on macro names

Section: 17.6.3.3.1 [macro.names] Status: New Submitter: Alberto Ganesh Barbati Opened: 2010-11-16 Last modified: 2010-11-17

View all other issues in [macro.names].

View all issues with New status.

Discussion:

A program is currently forbidden to use keywords as macro names. This restriction should be strengthened to include all identifiers that could be used by the library as attribute-tokens (for example noreturn, which is used by header <cstdlib>) and the special identifiers introduced recently for override control (these are not currently used in the library public interface, but could potentially be used by the implementation or in future revisions of the library).

Proposed resolution:

Modify 17.6.3.3.1 [macro.names] paragraph 2 as follows:

A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table X [Identifiers with special meaning] or to the attribute-tokens described in clause 7.6 [dcl.attr].

2015. Incorrect pre-conditions for some type traits

Section: 20.7.4 [meta.unary] Status: New Submitter: Nikolay Ivchenkov Opened: 2010-11-08 Last modified: 2010-11-17

View all other issues in [meta.unary].

View all issues with New status.

Discussion:

According to N3126 ‑ 3.9/9,

"Scalar types, trivial class types (Clause 9), arrays of such types and cv‑qualified versions of these types (3.9.3) are collectively called trivial types."

Thus, an array (possibly of unknown bound) can be trivial type, non‑trivial type, or an array type whose triviality cannot be determined because its element type is incomplete.

According to N3126 ‑ Table 45, preconditions for std::is_trivial are defined as follows:

"T shall be a complete type, (possibly cv-qualified) void, or an array of unknown bound"

It seems that "an array of unknown bound" should be changed to "an array of unknown bound of a complete element type". Preconditions for some other templates (e.g., std::is_trivially_copyable, std::is_standard_layout, std::is_pod, and std::is_literal_type) should be changed similarly.

On the other hand, some preconditions look too restrictive. For example, std::is_empty and std::is_polymorphic might accept any incomplete non-class type.

Proposed resolution:


2016. Allocators must be no-throw swappable

Section: 20.2.5 [allocator.requirements] Status: New Submitter: Daniel Krügler Opened: 2010-11-17 Last modified: 2010-11-23

View all other issues in [allocator.requirements].

View all issues with New status.

Discussion:

During the Batavia meeting it turned out that there is a definition hole for types satisfying the Allocators requirements: The problem became obvious when it was discussed whether all swap functions of Containers with internal data handles can be safely tagged with noexcept or not. While it is correct that the implicit swap function of an allocator is required to be a no-throw operation (because move/copy-constructors and assignment operators are required to be no-throw functions), there are no such requirements for specialized swap overloads for a particular allocator. But this requirement is essential because the Containers are required to support swappable Allocators, when the value allocator_traits<>::propagate_on_container_swap evaluates to true.

Proposed resolution:


2017. std::reference_wrapper makes incorrect usage of std::result_of

Section: 20.8.4 [refwrap] Status: New Submitter: Nikolay Ivchenkov Opened: 2010-11-15 Last modified: 2010-11-23

View all other issues in [refwrap].

View all issues with New status.

Discussion:

std::reference_wrapper's function call operator uses wrong type encoding for rvalue-arguments. An rvalue-argument of type T must be encoded as T&&, not as just T.
#include <functional>
#include <iostream>
#include <string>
#include <type_traits>
#include <utility>

template <class F, class... Types>
     typename std::result_of<F (Types...)>::type
         f1(F f, Types&&... params)
{
     return f(std::forward<Types...>(params...));
}

template <class F, class... Types>
     typename std::result_of<F (Types&&...)
         f2(F f, Types&&... params)
{
     return f(std::forward<Types...>(params...));
}

struct Functor
{
     template <class T>
         T&& operator()(T&& t) const
     {
         return static_cast<T&&>(t);
     }
};

int main()
{
     typedef std::string const Str;
     std::cout << f1(Functor(), Str("1")) << std::endl; // (1)
     std::cout << f2(Functor(), Str("2")) << std::endl; // (2)
}
Lets consider the function template f1 (which is similar to std::reference_wrapper's function call operator). In the invocation (1) F is deduced as 'Functor' and Types is deduced as type sequence which consists of one type 'std::string const'. After the substitution we have the following equivalent:
template <>
    std::result_of<F (std::string const)>::type
        f1<Functor, std::string const>(Functor f, std::string const && params)
{
    return f(std::forward<const std::string>(params));
}
The top-level cv-qualifier in the parameter type of 'F (std::string const)' is removed, so we have
template <>
    std::result_of<F (std::string)>::type
        f1<Functor, std::string const>(Functor f, std::string const && params)
{
    return f(std::forward<const std::string>(params));
}
Let r be an rvalue of type 'std::string' and cr be an rvalue of type 'std::string const'. The expression Str("1") is cr. The corresponding return type for the invocation
Functor().operator()(r)
is 'std::string &&'. The corresponding return type for the invocation
Functor().operator()(cr)
is 'std::string const &&'.

std::result_of<Functor (std::string)>::type is the same type as the corresponding return type for the invocation Functor().operator()(r), i.e. it is 'std::string &&'. As a consequence, we have wrong reference binding in the return statement in f1.

Now lets consider the invocation (2) of the function template f2. When the template arguments are substituted we have the following equivalent:

template <>
    std::result_of<F (std::string const &&)>::type
        f2<Functor, std::string const>(Functor f, std::string const && params)
{
    return f(std::forward<const std::string>(params));
}
std::result_of<F (std::string const &&)>::type is the same type as 'std::string const &&'. This is correct result.

Proposed resolution:


2018. regex_traits::isctype Returns clause is wrong

Section: 28.7 [re.traits] Status: New Submitter: Jonathan Wakely Opened: 2010-11-16 Last modified: 2010-11-23

View all other issues in [re.traits].

View all issues with New status.

Discussion:

28.7 [re.traits] p12 says:

returns true if f bitwise ored with the result of calling lookup_classname with an iterator pair that designates the character sequence "w" is not equal to 0 and c == _

If the bitmask value corresponding to "w" has a non-zero value (which it must do) then the bitwise or with any value is also non-zero, and so isctype('_', f) returns true for any f. Obviously this is wrong, since '_' is not in every ctype category.

There's a similar problem with the following phrases discussing the "blank" char class.

Proposed resolution:

Replace the Returns clause with a description in terms of ctype categories, rather than pseudocode in terms of bitwise operations. (full replacement wording to follow)


2019. isblank not supported by std::locale

Section: 22.3.3.1 [classification] Status: New Submitter: Jonathan Wakely Opened: 2010-11-16 Last modified: 2010-11-23

View all issues with New status.

Discussion:

C99 added isblank and iswblank to <locale.h> but <locale> does not provide any equivalent.

Proposed resolution:

Add to 22.3.3.1 [classification] synopsis:

template <class charT> bool isgraph (charT c, const locale& loc);
template <class charT> bool isblank (charT c, const locale& loc);

Add to 22.4.1 [category.ctype] synopsis:

static const mask xdigit = 1 << 8;
static const mask blank = 1 << 9;
static const mask alnum = alpha | digit;
static const mask graph = alnum | punct;