This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Adopted at the February, 2016 meeting.]
In an example like:
extern int i; namespace { constexpr int& r = i; } inline int f() { return r; }
use of f() in multiple translation units results in an ODR violation because of use of the internal-linkage reference r. It would be helpful if 6.3 [basic.def.odr] paragraph 6 could be amended to “look through” a constexpr reference in determining whether an inline function violates the ODR or not.
Proposed resolution (January, 2016):
Change 6.3 [basic.def.odr] bullet 6.2 as follows, dividing the running text into a bulleted list:
...Given such an entity named D defined in more than one translation unit, then
each definition of D shall consist of the same sequence of tokens; and
in each definition of D, corresponding names, looked up according to 6.5 [basic.lookup], shall refer to an entity defined within the definition of D, or shall refer to the same entity, after overload resolution (12.2 [over.match]) and after matching of partial template specialization (13.10.4 [temp.over]), except that a name can refer to
a non-volatile const object with internal or no linkage if the object
has the same literal type in all definitions of D,
and
the objectis initialized with a constant expression (7.7 [expr.const]),and
the objectis not odr-used, and
the objecthas the same value in all definitions of D,or
a reference with internal or no linkage initialized with a constant expression such that the reference refers to the same entity in all definitions of D;
and
in each definition of D, corresponding entities...