On 2/19/19 12:03 PM, Jakub Jelinek wrote:
On Tue, Feb 19, 2019 at 11:28:22AM -1000, Jason Merrill wrote:
On Tue, Feb 19, 2019 at 4:00 AM Jakub Jelinek <ja...@redhat.com> wrote:
On Mon, Feb 18, 2019 at 03:01:14PM -1000, Jason Merrill wrote:
But it's not clear to me that the standard actually allows this.  I don't
think changing the active member of a union in the mem-initializer for
another member is reasonable.

There is in [expr.const]/2:

an lvalue-to-rvalue conversion (7.1) that is applied to a glvalue that refers 
to a non-active member of a
union or a subobject thereof;

an assignment expression (8.18) or invocation of an assignment operator (15.8) 
that would change the
active member of a union;

in C++17 it seems, so maybe my union testcases are accepts-invalid.
This has been introduced in P0137R1 and removed again in P1330R0.  Does that
mean e.g. following is valid in C++14, invalid in C++17 and valid again in
C++20?  Or has one of the above papers changed retroactively previous
standards?

Before P0137 I believe foo and bar were arguably undefined.

I see, before that it was:
"an lvalue-to-rvalue conversion (4.1) or modification (5.18, 5.2.6, 5.3.2) that 
is applied
to a glvalue that refers to a non-active member of a union or a subobject 
thereof;"

So, do we want something like this then (or free all vectors immediately
there and return immediately)?

2019-02-19  Jakub Jelinek  <ja...@redhat.com>

        PR c++/89336
        * constexpr.c (cxx_eval_store_expression): Diagnose changing of active
        union member for -std=c++17 and earlier.

OK.  I don't think it's important to return immediately.

Jason

Reply via email to