Subject: Re: [ub] Possible effective type defect
From: David Krauss (david_work_at_[hidden])
Date: 2014-02-21 23:21:58
Yes, not only does it apply only to lvalue expressions, it only applies with lvalue-to-rvalue conversion, which happens less often in C++ and when applied to class types, it gets short-circuited to a copy constructor call.
All the examples in the DR refer to lvalue-to-rvalue conversion applied by the comma operator, which doesnt happen in C++ because value category tends to propagate. Analogous arguments can be formed by replacing them with static_cast to non-reference types. In C++ this unambiguously creates new objects with unique addresses, so type punning by static_cast is either OK for trivially copyable unions (N3797 §12.8/16), or dependent on the copy constructor.
I think it would be better to fill the role of effective type with a concept orthogonal to lvalue-to-rvalue conversion.
On Feb 22, 2014, at 1:10 AM, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
> The recent (and ongoing) discussion on the lifetime of objects of type at the intersection of C and C++ (what we used to call POD) looked at various aspects of C's notion 'effective type'. Here is one defect filled against it:
> Please note that it is for the C committee to decide. I am mentioning it here only to the extent that 'effective type' is part of what we are looking at.
> -- Gaby
> ub mailing list
SG12 list run by herb.sutter at gmail.com