On 05/15/18 18:13, Andrew Giese wrote:
> I agree with you assessment, Belloc; a *is *odr-used in that expression
> and therefore linking should fail.
Thing is the compiler has no reason to reference `a` in this code. I
think, if we have to change something in regard to this case, it should
be the standard, which should make it implementation-defined.
> On Tue, May 15, 2018 at 8:47 AM, Belloc <
jabe...@gmail.com
> <mailto:
jabe...@gmail.com>> wrote:
>
>
>
> On Tuesday, May 15, 2018 at 7:58:44 AM UTC-3, Andrew Giese wrote:
>
> @Richard Smith,
> The code sample you provided compiles but doesn't link. Perhaps
> we should make that distinction. I don't think we could write
> any (well formed) expression using a that is guaranteed to fail
> to compile because another translation unit may provide the
> definition at link time.
>
>
> You are correct. I should have used the terms "link(ed)" instead of
> "compile(ed)" in my first post. My question should then be
> rephrased: "CGC, clang and VS2017 link this code. Are they correct?".
>
> According to [basic.def.odr]/4
> <
http://eel.is/c++draft/basic.def.odr#4> I think the variable a *is*
> odr-used in the expression std::cout << a.k << '\n'; as the name a
> doesn't satisfy the condition
>
> if x is an object, ex is an element of the set of potential
> results of an expression e, where
> either the lvalue-to-rvalue conversion (7.1) is applied to e, or
> e is a discarded-value expression (8.2).
>
>
> in the alluded paragraph. Therefore, I believe the code in my first
> post should *not* link, because the compiler should not be allowed
> to replace a.k by 1 in the expression std::cout << a.k << '\n'; at
> compile time.
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ISO C++ Standard - Discussion" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to
std-discussio...@isocpp.org
> <mailto:
std-discussio...@isocpp.org>.
> <mailto:
std-dis...@isocpp.org>.
> <
https://groups.google.com/a/isocpp.org/group/std-discussion/>.
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ISO C++ Standard - Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
std-discussio...@isocpp.org
> <mailto:
std-discussio...@isocpp.org>.
> <mailto:
std-dis...@isocpp.org>.