Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


2175. Ambiguity with attribute in conversion operator declaration

Section:9.3.3  [dcl.ambig.res]    Status:CD4    Submitter:Daveed Vandevoorde    Date:2015-09-17

[Adopted at the February, 2016 meeting.]

The declaration

  operator int [[noreturn]] ();

is ambiguous with respect to the binding of the attribute. Itcould either be parsed (as apparently intended by the user) aspart of thenoptr-declarator (9.3 [dcl.decl] paragraph 4) or as part of thetype-specifier-seq(9.2.9 [dcl.type] paragraph 1) of theconversion-type-id (11.4.8.3 [class.conv.fct] paragraph 1). Current implementations disambiguate thisdeclaration in favor of the latter interpretation, issuing anerror for the declaration because thenoreturnattribute cannot apply to a type.

Proposed resolution (February, 2016):

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

Theconversion-type-id shall not represent a functiontype nor an array type. Theconversion-type-id inaconversion-function-id is the longestpossiblesequence ofconversion-declaratorstokens that could possibly form aconversion-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 themultiplication operator. —endexample]This rule also prevents ambiguities forattributes. [Example:

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

end example]end note]




[8]ページ先頭

©2009-2026 Movatter.jp