Date: Thu, 14 Nov 2024 11:14:26 +0100
On 2024-11-14 at 11:07, Russell Shaw via Std-Discussion wrote:
> Hi,
>
> In 14882:2024 at point [A], why is "S::x is not odr-used here" ?
>
> "Odr-use" is not explained well.
>
> ------------------------------------------------
> 6.3 One-definition rule [basic.def.odr]
>
> example 1
>
> In the following example, the set of potential results of the
> initializer of n contains the first S::x subexpression, but not the
> second S::x subexpression.
>
> struct S { static const int x = 0; };
>
> const int &f(const int &r);
>
> int n = b ? (1, S::x) // S::x is not odr-used here <------ [A]
> : f(S::x); // S::x is odr-used here, so a definition is
> required
> ------------------------------------------------
The function f takes a reference parameter. That requires S::x to *have*
an address, so it can be referred to. Just using its value does not
require it to be stored anywhere.
> Hi,
>
> In 14882:2024 at point [A], why is "S::x is not odr-used here" ?
>
> "Odr-use" is not explained well.
>
> ------------------------------------------------
> 6.3 One-definition rule [basic.def.odr]
>
> example 1
>
> In the following example, the set of potential results of the
> initializer of n contains the first S::x subexpression, but not the
> second S::x subexpression.
>
> struct S { static const int x = 0; };
>
> const int &f(const int &r);
>
> int n = b ? (1, S::x) // S::x is not odr-used here <------ [A]
> : f(S::x); // S::x is odr-used here, so a definition is
> required
> ------------------------------------------------
The function f takes a reference parameter. That requires S::x to *have*
an address, so it can be referred to. Just using its value does not
require it to be stored anywhere.
Received on 2024-11-14 10:14:28