Throwing an array of unknown size
14.2 [except.throw]
Mike Miller

Created on 2005-01-19.00:00:00 last changed 144 months ago


Date: 2009-03-15.00:00:00

[Voted into the WP at the March, 2009 meeting.]

Date: 2006-10-15.00:00:00

Proposed resolution (October, 2006)

Change 14.2 [except.throw] paragraph 3 as indicated:

...The type of the throw-expression shall not If the type of the exception object would be an incomplete type, or a pointer to an incomplete type other than (possibly cv-qualified) void the program is ill-formed...
Date: 2005-04-15.00:00:00

Notes from the April, 2005 meeting:

The CWG agreed that the example should be permitted. Note that the reference to throw-expression in the cited text is incorrect; a throw-expression includes the throw keyword and is always of type void. This wording problem is addressed in the proposed resolution for issue 475.

Date: 2005-01-19.00:00:00

According to 14.2 [except.throw] paragraph 3,

The type of the throw-expression shall not be an incomplete type, or a pointer to an incomplete type other than (possibly cv-qualified) void.

This disallows cases like the following, because str has an incomplete type (an array of unknown size):

    extern const char str[];
    void f() {
        throw str;

The array-to-pointer conversion is applied to the operand of throw, so there's no problem creating the exception object, which is the reason for the restriction on incomplete types. I believe this case should be permitted.

Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-08-03 00:00:00adminsetstatus: dr -> wp
2009-03-23 00:00:00adminsetmessages: + msg2031
2009-03-23 00:00:00adminsetstatus: ready -> dr
2008-10-05 00:00:00adminsetstatus: review -> ready
2006-11-05 00:00:00adminsetmessages: + msg1410
2006-11-05 00:00:00adminsetstatus: drafting -> review
2005-05-01 00:00:00adminsetmessages: + msg1169
2005-05-01 00:00:00adminsetstatus: open -> drafting
2005-01-19 00:00:00admincreate