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

### 2378. Behaviour of standard exception types

Section: 17.6.4.1 [bad.alloc], 17.6.4.2 [new.badlength], 17.7.4 [bad.cast], 17.7.5 [bad.typeid], 17.9.4 [bad.exception] Status: C++17 Submitter: Andy Sawyer Opened: 2014-03-31 Last modified: 2017-07-30

Priority: 0

View all issues with C++17 status.

Discussion:

I think we have an issue with the specification of some of the standard exception types. In particular, several of them have default constructors with remarks to the effect that "The result of calling `what()` on the newly constructed object is implementation-defined". (In some cases this is contradictory to a further specification of `what()`, which is specified to return an implementation-defined NTBS.)

Previous resolution from Andy [SUPERSEDED]:

> This wording is relative to N3936.

> 1. Edit 17.6.4.1 [bad.alloc] p3 as indicated:

>    >     bad_alloc() noexcept;

>    > > […]

>    > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined `what()` returns an implementation-defined NTBS.

> 2. Edit 17.6.4.2 [new.badlength] p3 as indicated: [Drafting note: Added the Postcondition, since we don't say anything else about `bad_array_new_length::what()` — end of note]

>    >     bad_array_new_length() noexcept;

>    > > […]

>    > > -3- Remarks Postcondition: The result of calling `what()` on the newly constructed object is implementation-defined `what()` returns an implementation-defined NTBS.

> 3. Edit 17.7.4 [bad.cast] p3 as indicated:

>    >     bad_cast() noexcept;

>    > > […]

>    > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined..

> 4. Edit 17.7.5 [bad.typeid] p3 as indicated:

>    >     bad_typeid() noexcept;

>    > > […]

>    > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined..

> 5. Edit 17.9.4 [bad.exception] p3 as indicated:

>    >     bad_exception() noexcept;

>    > > […]

>    > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined..

[2014-06-17, Rapperswil]

Jonathan provides alternative wording.

[2015-02, Cologne]

NJ: I don't know why we need the explict statement about `what()` here, since `bad_array_new_length` already derives.
AM: yes.
NJ: Then "what()" is missing from the synopsis.
AM: Yes, that's an error and it needs to be added.

Conclusion: Update the wording to add the missing entry in the synopsis.

AM: The issue needs another update; we need to add missing "Remarks". DK updates the paper.
AM: Any objections to "tentatively ready"? No objections.

Proposed resolution:

This wording is relative to N4296.

1. Edit 17.6.4.1 [bad.alloc] p3 as indicated:

   >     bad_alloc() noexcept;

   > > […]

   > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined.

2. Edit 17.6.4.1 [bad.alloc] p5 as indicated:

   >     virtual const char* what() const noexcept;

   > > -5- Returns: An implementation-defined NTBS.

   > > -?- Remarks: The message may be a null-terminated multibyte string (17.5.2.1.4.2), suitable for conversion and display as a `wstring` (21.3, 22.4.1.4).

3. Edit class `bad_array_new_length` synopsis 17.6.4.2 [new.badlength] as indicated:

   >     namespace std {
   >       class bad_array_new_length : public bad_alloc {
   >       public:
   >         bad_array_new_length() noexcept;
   >         virtual const char* what() const noexcept;
   >       };
   >     }

4. Edit 17.6.4.2 [new.badlength] as indicated:

   >     bad_array_new_length() noexcept;

   > > […]

   > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined.

   >     virtual const char* what() const noexcept;

   > > -?- Returns: An implementation-defined NTBS.

   > > -?- Remarks: The message may be a null-terminated multibyte string (17.5.2.1.4.2), suitable for conversion and display as a `wstring` (21.3, 22.4.1.4).

5. Edit 17.7.4 [bad.cast] p3 as indicated:

   >     bad_cast() noexcept;

   > > […]

   > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined..

6. Edit 17.7.5 [bad.typeid] p3 as indicated:

   >     bad_typeid() noexcept;

   > > […]

   > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined..

7. Edit 17.9.4 [bad.exception] p3 as indicated:

   >     bad_exception() noexcept;

   > > […]

   > > -3- Remarks: The result of calling `what()` on the newly constructed object is implementation-defined..