Created on 2025-12-18.00:00:00 last changed 1 week ago
Suggested resolution:
Change in 6.3 [basic.def.odr] paragraph 5 as follows:
A variable is named by an expression if the expression is an id-expression or splice-expression (7.5.9 [expr.prim.splice]) that designates it. A variable x that is named by a potentially-evaluated expression N that appears at a point P is odr-used by N unless
- x is a reference that is usable in constant expressions at P (7.7 [expr.const]), or ...
- ...
Consider:
export module M; static int x; // OK, TU-local static int &rx = x; // OK, TU-local export inline int &f() { return rx; // OK(!), not an odr-use }
The declaration of f is not an exposure because the reference to rx is not an odr-use (6.7 [basic.link] bullet 14.4), but it is impossible with current implementation technology to simulate naming x in importing translation units.
For a related example:
export module M; static int x; // OK, TU-local extern "C++" int &rx = x; // OK, not an exposure (not constexpr) export inline int &f() { return rx; // OK(!), not an odr-use }
In importing translation units, rx is not usable in constant expressions.
Finally:
export module M;
extern "C++" int x = 0;
static int &rx = x;
export constexpr inline int &f() {
return rx; // OK, not an odr-use
}
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-01-08 17:03:18 | admin | set | messages: + msg8451 |
| 2025-12-18 00:00:00 | admin | create | |