Title
Ambiguity with attribute in conversion operator declaration
Status
cd4
Section
9.3.3 [dcl.ambig.res]
Submitter
Daveed Vandevoorde

Created on 2015-09-17.00:00:00 last changed 86 months ago

Messages

Date: 2016-02-15.00:00:00

Proposed resolution (February, 2016):

Change 11.4.8.3 [class.conv.fct] paragraph 3 as follows:

The conversion-type-id shall not represent a function type nor an array type. The conversion-type-id in a conversion-function-id is the longest possible sequence of conversion-declarators tokens that could possibly form a conversion-type-id. [Note: This prevents ambiguities between the declarator operator * and its expression counterparts. [Example:

  &ac.operator int*i;  // syntax error:
                       // parsed as: &(ac.operator int *)i
                       // not as: &(ac.operator int)*i

The * is the pointer declarator and not the multiplication operator. —end example] This rule also prevents ambiguities for attributes. [Example:

  operator int [[noreturn]] (); // error: noreturn attribute applied to a type

end example]end note]

Date: 2016-02-15.00:00:00

[Adopted at the February, 2016 meeting.]

The declaration

  operator int [[noreturn]] ();

is ambiguous with respect to the binding of the attribute. It could either be parsed (as apparently intended by the user) as part of the noptr-declarator (9.3 [dcl.decl] paragraph 4) or as part of the type-specifier-seq (9.2.9 [dcl.type] paragraph 1) of the conversion-type-id (11.4.8.3 [class.conv.fct] paragraph 1) . Current implementations disambiguate this declaration in favor of the latter interpretation, issuing an error for the declaration because the noreturn attribute cannot apply to a type.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: tentatively ready -> cd4
2016-02-15 00:00:00adminsetmessages: + msg5704
2016-02-15 00:00:00adminsetstatus: drafting -> tentatively ready
2015-09-17 00:00:00admincreate