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 ,
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...
and
the object is initialized with a constant
expression (7.7 [expr.const]), and
the object is not odr-used, andthe object has the same value in all
definitions of D ,
[Adopted at the February, 2016 meeting.] In an example like: 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.
extern int i;
namespace {
constexpr int& r = i;
}
inline int f() { return r; }