CWG Issue 765 (original) (raw)

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

2025-04-13


765. Local types in inline functions with external linkage

Section: 9.2.3 [dcl.fct.spec]Status: CD2Submitter: Mike MillerDate: 6 February, 2009

[Voted into WP at March, 2010 meeting.]

9.2.3 [dcl.fct.spec] paragraph 4 specifies that local static variables and string literals appearing in the body of an inline function with external linkage must be the same entities in every translation unit in the program. Nothing is said, however, about whether local types are likewise required to be the same.

Although a conforming program could always have determined this by use of typeid, recent changes to C++ (allowing local types as template type arguments, lambda expression closure classes) make this question more pressing.

Notes from the July, 2009 meeting:

The types are intended to be the same.

Proposed resolution (November, 2009):

Change 9.2.3 [dcl.fct.spec] paragraph 4 as follows:

...A static local variable in an extern inlinefunction always refers to the same object. A string literal in the body of an extern inline function is the same object in different translation units. [Note: A string literal appearing in a default argument expression is not in the body of an inline function merely because the expression is used in a function call from that inline function. —_end note_] A type defined within the body of an extern inline function is the same type in every translation unit.