Created on 2024-11-06.00:00:00 last changed 2 weeks ago
(From submissions #634 and #637.)
The standard permits that references do not occupy storage. The term "access" (3.1 [defns.access]) is not applicable to references. Yet, references can participate in data races (6.9.1 [intro.execution] paragraph 10, 6.9.2.2 [intro.races] paragraph 2). For example:
int x, y; struct S { int &r; } s{x}; void thread_1() { new (&s) S{y}; // transparent replacement } void thread_2() { auto& r = s.r; // OK ?! Refers to x or y? }
Also consider the impact on constant evaluation:
int n{}; struct S { int& r; }; constexpr S s{n}; constexpr volatile S s2{n}; static_assert(&static_cast<const volatile S&>(s).r == &n); // GCC rejects static_assert(&s2.r == &n); // GCC and Clang reject
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-11-06 00:00:00 | admin | create |