Title
Reference binding of incompatible array types
Status
nad
Section
9.4.4 [dcl.init.ref]
Submitter
Johannes Schaub

Created on 2010-03-20.00:00:00 last changed 165 months ago

Messages

Date: 2011-03-15.00:00:00

Rationale (March, 2011):

In consideration of the arguments made in issue 1232, CWG agreed to allow array temporaries and there is thus no reason to prohibit them in this case.

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

Change 9.4.4 [dcl.init.ref] paragraph 5 as follows:

  • ...

  • If the initializer expression is a string literal (5.13.5 [lex.string]), the program is ill-formed.

  • Otherwise, a temporary of type...

(See also issue 1232, which argues in favor of allowing array temporaries.)

Date: 2010-11-15.00:00:00

Notes from the November, 2010 meeting:

The CWG agreed that the current wording appears to permit this example but still felt that array temporaries are undesirable. Wording should be added to disallow this usage.

Date: 2010-10-15.00:00:00

Note (October, 2010):

Although in general an object of array type cannot be initialized from another object of array type, there is special provision in 9.4.3 [dcl.init.string] for doing so when the source object is a string literal, as in this example. The issue is thus being reopened for further consideration in this light.

Date: 2010-08-15.00:00:00

Rationale (August, 2010):

The Standard does not describe initialization of array temporaries, so a program that requires such is ill-formed.

Date: 2022-11-20.07:54:16

According to the logic in 9.4.4 [dcl.init.ref] paragraph 5, the following example should create a temporary array and bind the reference to that temporary:

    const char (&p)[10] = "123";

That is presumably not intended (issue 450 calls a similar outcome for rvalue arrays “implausible”). Current implementations reject this example.

History
Date User Action Args
2011-04-10 00:00:00adminsetmessages: + msg3413
2011-04-10 00:00:00adminsetstatus: review -> nad
2010-11-29 00:00:00adminsetmessages: + msg3093
2010-11-29 00:00:00adminsetmessages: + msg3092
2010-11-29 00:00:00adminsetstatus: open -> review
2010-10-18 00:00:00adminsetmessages: + msg3031
2010-10-18 00:00:00adminsetstatus: nad -> open
2010-08-23 00:00:00adminsetmessages: + msg2947
2010-08-23 00:00:00adminsetstatus: open -> nad
2010-03-20 00:00:00admincreate