C++ Logo


Advanced search

Re: [ub] Possible effective type defect

From: David Krauss <david_work_at_[hidden]>
Date: Sat, 22 Feb 2014 13:21:58 +0800
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 doesn’t 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.

        - D

On Feb 22, 2014, at 1:10 AM, Gabriel Dos Reis <gdr_at_[hidden]> wrote:

> Hi,
> 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:
> http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1762.htm
> 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
> ub_at_[hidden]
> http://www.open-std.org/mailman/listinfo/ub

Received on 2014-02-22 06:22:16