public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error
@ 2012-07-12  2:55 nuller0222 at gmail dot com
  2014-11-26 16:49 ` [Bug c++/53932] C++ " paolo.carlini at oracle dot com
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: nuller0222 at gmail dot com @ 2012-07-12  2:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

             Bug #: 53932
           Summary: [4.3 regression]C++ reference variable to member of
                    anonymous union in global is error
    Classification: Unclassified
           Product: gcc
           Version: 4.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nuller0222@gmail.com


cat prog.cpp
static union { int i; };
int& r = i;
int main() { return r; }

g++ prog.cpp
/tmp/ccIAPctI.o::(.rdata+0x0): undefined reference to `_i'
collect2: ld returned 1 exit status


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
@ 2014-11-26 16:49 ` paolo.carlini at oracle dot com
  2021-07-24 16:10 ` [Bug c++/53932] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-26 16:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-26
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [9/10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
  2014-11-26 16:49 ` [Bug c++/53932] C++ " paolo.carlini at oracle dot com
@ 2021-07-24 16:10 ` pinskia at gcc dot gnu.org
  2021-09-22  7:41 ` pinskia at gcc dot gnu.org
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-24 16:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.5
   Last reconfirmed|2014-11-26 00:00:00         |2021-7-24
           Keywords|                            |assemble-failure,
                   |                            |link-failure
            Summary|C++ reference variable to   |[9/10/11/12 Regression] C++
                   |member of anonymous union   |reference variable to
                   |in global is error          |member of anonymous union
                   |                            |in global is error

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [9/10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
  2014-11-26 16:49 ` [Bug c++/53932] C++ " paolo.carlini at oracle dot com
  2021-07-24 16:10 ` [Bug c++/53932] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2021-09-22  7:41 ` pinskia at gcc dot gnu.org
  2021-09-22  7:42 ` pinskia at gcc dot gnu.org
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-22  7:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |asolokha at gmx dot com

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 92981 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [9/10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-22  7:41 ` pinskia at gcc dot gnu.org
@ 2021-09-22  7:42 ` pinskia at gcc dot gnu.org
  2022-01-17 15:24 ` rguenth at gcc dot gnu.org
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-22  7:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For LTO, we ICE.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [9/10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (3 preceding siblings ...)
  2021-09-22  7:42 ` pinskia at gcc dot gnu.org
@ 2022-01-17 15:24 ` rguenth at gcc dot gnu.org
  2022-01-21 13:56 ` rguenth at gcc dot gnu.org
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 15:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
with

> ./cc1plus -quiet t.ii -flto
during IPA pass: modref
t.ii:3:24: internal compiler error: in get_partitioning_class, at symtab.c:2095
    3 | int main() { return r; }
      |                        ^
0x1111438 symtab_node::get_partitioning_class()
        /home/rguenther/src/gcc3/gcc/symtab.c:2095
0x159f81c lto_output_varpool_node
        /home/rguenther/src/gcc3/gcc/lto-cgraph.c:622
0x15a079e output_symtab()
        /home/rguenther/src/gcc3/gcc/lto-cgraph.c:989
0x15bd1bd lto_output()
        /home/rguenther/src/gcc3/gcc/lto-streamer-out.c:2813
0x16a3a79 write_lto
        /home/rguenther/src/gcc3/gcc/passes.c:2761
(gdb) p node->debug()
i/3 (i) @0x7ffff66c1100
  Type: variable
  Body removed by symtab_remove_unreachable_nodes
  Visibility: semantic_interposition artificial
  References: 
  Referring: r/1 (addr) 
  Availability: not_available
  Varpool flags:
$2 = void

so we somehow remove the variable because either the DECL_INITIAL walks do not
work or because the C++ FE screws up in setting things up.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [9/10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-01-17 15:24 ` rguenth at gcc dot gnu.org
@ 2022-01-21 13:56 ` rguenth at gcc dot gnu.org
  2022-05-27  9:34 ` [Bug c++/53932] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-21 13:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-01-21 13:56 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:34 ` rguenth at gcc dot gnu.org
  2022-06-28 10:30 ` jakub at gcc dot gnu.org
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-05-27  9:34 ` [Bug c++/53932] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:30 ` jakub at gcc dot gnu.org
  2023-01-19 13:58 ` rguenth at gcc dot gnu.org
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (7 preceding siblings ...)
  2022-06-28 10:30 ` jakub at gcc dot gnu.org
@ 2023-01-19 13:58 ` rguenth at gcc dot gnu.org
  2023-01-19 14:00 ` rguenth at gcc dot gnu.org
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-19 13:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
           Keywords|                            |wrong-code

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The C++ frontend mangles union { int i; };

        .local  _ZL1i
        .comm   _ZL1i,4,4

but not the reference to the anonymous union member:

        .globl  r
        .data
        .align 8
        .type   r, @object
        .size   r, 8
r:
        .quad   i

they are even different decls:

i/3 (int i)
  Type: variable
  Body removed by symtab_remove_unreachable_nodes
  Visibility: semantic_interposition artificial
  References:
  Referring: r/1 (addr)
  Availability: not_available
  Varpool flags:
r/1 (int& r)
  Type: variable definition analyzed
  Visibility: force_output externally_visible semantic_interposition no_reorder
asm_written public
  Aux: @0x1
  References: i/3 (addr)
  Referring:
  Availability: available
  Varpool flags: initialized read-only const-value-known
_ZL1i/0 (_ZL1i)
  Type: variable definition analyzed
  Visibility: force_output semantic_interposition no_reorder
prevailing_def_ironly asm_written
  Aux: @0x7ffff7ff3100
  References:
  Referring:
  Availability: available
  Varpool flags:

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (8 preceding siblings ...)
  2023-01-19 13:58 ` rguenth at gcc dot gnu.org
@ 2023-01-19 14:00 ` rguenth at gcc dot gnu.org
  2023-01-19 14:09 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-19 14:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|assemble-failure            |

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
clang produces

r:
        .quad   _Z1i

so it seems that something goes wrong in the C++ frontend.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (9 preceding siblings ...)
  2023-01-19 14:00 ` rguenth at gcc dot gnu.org
@ 2023-01-19 14:09 ` jakub at gcc dot gnu.org
  2023-01-19 16:51 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-19 14:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It isn't just references:
static union { int i; };
int &r = i;
int s = i;
int *t = &i;

void
foo (int **p, int *q)
{
  *p = &i;
  *q = i;
}

Inside of the function or global constructor for s it works ok.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (10 preceding siblings ...)
  2023-01-19 14:09 ` jakub at gcc dot gnu.org
@ 2023-01-19 16:51 ` jakub at gcc dot gnu.org
  2023-01-19 17:30 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-19 16:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, the problem is that build_anon_union_vars builds artificial variables for
the anon union members and they those VAR_DECLs have DECL_VALUE_EXPR set to the
D.2763.i and similar COMPONENT_REFs.  But VAR_DECLs with DECL_VALUE_EXPRs are
only actually replaced with those DECL_VALUE_EXPR expressions during
gimplification or regimplification (which explains why it works fine inside of
code in functions or global constructors).
Nothing replaces them in DECL_INITIAL expressions of statically initialized
vars.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (11 preceding siblings ...)
  2023-01-19 16:51 ` jakub at gcc dot gnu.org
@ 2023-01-19 17:30 ` jakub at gcc dot gnu.org
  2023-01-19 22:28 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-19 17:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54311
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54311&action=edit
gcc13-pr53932.patch

Untested fix.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (12 preceding siblings ...)
  2023-01-19 17:30 ` jakub at gcc dot gnu.org
@ 2023-01-19 22:28 ` cvs-commit at gcc dot gnu.org
  2023-01-19 22:33 ` [Bug c++/53932] [10/11/12 " jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-19 22:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:9b9a989adc042b304572fd6d4ade46b47be6ccb8

commit r13-5265-g9b9a989adc042b304572fd6d4ade46b47be6ccb8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 19 23:27:34 2023 +0100

    c++: Fix up handling of references to anon union members in initializers
[PR53932]

    For anonymous union members we create artificial VAR_DECLs which
    have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
    just fine inside of functions (including global dynamic constructors),
    because during gimplification such VAR_DECLs are gimplified as
    their DECL_VALUE_EXPR.  This is also done during regimplification.

    But references to these artificial vars in DECL_INITIAL expressions
    aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
    with link failures like on the testcase below, or worse ICEs with
    LTO.

    The following patch fixes those during cp_fully_fold_init where we
    already walk all the trees (!data->genericize means that
    function rather than cp_fold_function).

    2023-01-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/53932
            * cp-gimplify.cc (cp_fold_r): During cp_fully_fold_init replace
            DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
            DECL_VALUE_EXPR.

            * g++.dg/init/pr53932.C: New test.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (13 preceding siblings ...)
  2023-01-19 22:28 ` cvs-commit at gcc dot gnu.org
@ 2023-01-19 22:33 ` jakub at gcc dot gnu.org
  2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-19 22:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12/13 Regression]    |[10/11/12 Regression] C++
                   |C++ reference variable to   |reference variable to
                   |member of anonymous union   |member of anonymous union
                   |in global is error          |in global is error

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11/12 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (14 preceding siblings ...)
  2023-01-19 22:33 ` [Bug c++/53932] [10/11/12 " jakub at gcc dot gnu.org
@ 2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:55 ` [Bug c++/53932] [10/11 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:d4eca31c521f54a3066f9940fbf09e28b53eff8c

commit r12-9142-gd4eca31c521f54a3066f9940fbf09e28b53eff8c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 19 23:27:34 2023 +0100

    c++: Fix up handling of references to anon union members in initializers
[PR53932]

    For anonymous union members we create artificial VAR_DECLs which
    have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
    just fine inside of functions (including global dynamic constructors),
    because during gimplification such VAR_DECLs are gimplified as
    their DECL_VALUE_EXPR.  This is also done during regimplification.

    But references to these artificial vars in DECL_INITIAL expressions
    aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
    with link failures like on the testcase below, or worse ICEs with
    LTO.

    The following patch fixes those during cp_fully_fold_init where we
    already walk all the trees (!data->genericize means that
    function rather than cp_fold_function).

    2023-01-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/53932
            * cp-gimplify.cc (cp_fold_r): During cp_fully_fold_init replace
            DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
            DECL_VALUE_EXPR.

            * g++.dg/init/pr53932.C: New test.

    (cherry picked from commit 9b9a989adc042b304572fd6d4ade46b47be6ccb8)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (15 preceding siblings ...)
  2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:55 ` jakub at gcc dot gnu.org
  2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 17:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression] C++   |[10/11 Regression] C++
                   |reference variable to       |reference variable to
                   |member of anonymous union   |member of anonymous union
                   |in global is error          |in global is error

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for gcc 12.3 too.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (16 preceding siblings ...)
  2023-02-10 17:55 ` [Bug c++/53932] [10/11 " jakub at gcc dot gnu.org
@ 2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
  2023-05-03  9:24 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-02 20:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:bd34d694f4c060c92aee0e09edf4c7e1d83807e5

commit r11-10700-gbd34d694f4c060c92aee0e09edf4c7e1d83807e5
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 19 23:27:34 2023 +0100

    c++: Fix up handling of references to anon union members in initializers
[PR53932]

    For anonymous union members we create artificial VAR_DECLs which
    have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
    just fine inside of functions (including global dynamic constructors),
    because during gimplification such VAR_DECLs are gimplified as
    their DECL_VALUE_EXPR.  This is also done during regimplification.

    But references to these artificial vars in DECL_INITIAL expressions
    aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
    with link failures like on the testcase below, or worse ICEs with
    LTO.

    The following patch fixes those during cp_fully_fold_init where we
    already walk all the trees (!data->genericize means that
    function rather than cp_fold_function).

    2023-01-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/53932
            * cp-gimplify.c (cp_fold_r): During cp_fully_fold_init replace
            DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
            DECL_VALUE_EXPR.

            * g++.dg/init/pr53932.C: New test.

    (cherry picked from commit 9b9a989adc042b304572fd6d4ade46b47be6ccb8)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10/11 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (17 preceding siblings ...)
  2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03  9:24 ` jakub at gcc dot gnu.org
  2023-05-03 15:20 ` [Bug c++/53932] [10 " cvs-commit at gcc dot gnu.org
  2023-05-04  7:15 ` jakub at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-03  9:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.4 as well.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (18 preceding siblings ...)
  2023-05-03  9:24 ` jakub at gcc dot gnu.org
@ 2023-05-03 15:20 ` cvs-commit at gcc dot gnu.org
  2023-05-04  7:15 ` jakub at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 15:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:04cf6b57c7c467f615a16b7bbda574671e3fb2df

commit r10-11356-g04cf6b57c7c467f615a16b7bbda574671e3fb2df
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 19 23:27:34 2023 +0100

    c++: Fix up handling of references to anon union members in initializers
[PR53932]

    For anonymous union members we create artificial VAR_DECLs which
    have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
    just fine inside of functions (including global dynamic constructors),
    because during gimplification such VAR_DECLs are gimplified as
    their DECL_VALUE_EXPR.  This is also done during regimplification.

    But references to these artificial vars in DECL_INITIAL expressions
    aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
    with link failures like on the testcase below, or worse ICEs with
    LTO.

    The following patch fixes those during cp_fully_fold_init where we
    already walk all the trees (!data->genericize means that
    function rather than cp_fold_function).

    2023-01-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/53932
            * cp-gimplify.c (cp_fold_r): During cp_fully_fold_init replace
            DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
            DECL_VALUE_EXPR.

            * g++.dg/init/pr53932.C: New test.

    (cherry picked from commit 9b9a989adc042b304572fd6d4ade46b47be6ccb8)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug c++/53932] [10 Regression] C++ reference variable to member of anonymous union in global is error
  2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
                   ` (19 preceding siblings ...)
  2023-05-03 15:20 ` [Bug c++/53932] [10 " cvs-commit at gcc dot gnu.org
@ 2023-05-04  7:15 ` jakub at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-04  7:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on all supported release branches.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-05-04  7:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12  2:55 [Bug c++/53932] New: [4.3 regression]C++ reference variable to member of anonymous union in global is error nuller0222 at gmail dot com
2014-11-26 16:49 ` [Bug c++/53932] C++ " paolo.carlini at oracle dot com
2021-07-24 16:10 ` [Bug c++/53932] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-09-22  7:41 ` pinskia at gcc dot gnu.org
2021-09-22  7:42 ` pinskia at gcc dot gnu.org
2022-01-17 15:24 ` rguenth at gcc dot gnu.org
2022-01-21 13:56 ` rguenth at gcc dot gnu.org
2022-05-27  9:34 ` [Bug c++/53932] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:30 ` jakub at gcc dot gnu.org
2023-01-19 13:58 ` rguenth at gcc dot gnu.org
2023-01-19 14:00 ` rguenth at gcc dot gnu.org
2023-01-19 14:09 ` jakub at gcc dot gnu.org
2023-01-19 16:51 ` jakub at gcc dot gnu.org
2023-01-19 17:30 ` jakub at gcc dot gnu.org
2023-01-19 22:28 ` cvs-commit at gcc dot gnu.org
2023-01-19 22:33 ` [Bug c++/53932] [10/11/12 " jakub at gcc dot gnu.org
2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:55 ` [Bug c++/53932] [10/11 " jakub at gcc dot gnu.org
2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
2023-05-03  9:24 ` jakub at gcc dot gnu.org
2023-05-03 15:20 ` [Bug c++/53932] [10 " cvs-commit at gcc dot gnu.org
2023-05-04  7:15 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).