Bug 90432 - [9/10 Regression] Internal compiler error with no_unique_address empty type with constructor call followed by value initialized to non-zero
Summary: [9/10 Regression] Internal compiler error with no_unique_address empty type w...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.1.0
: P2 normal
Target Milestone: 9.3
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
: 93898 (view as bug list)
Depends on: 89089
Blocks:
  Show dependency treegraph
 
Reported: 2019-05-10 23:22 UTC by David Stone
Modified: 2020-03-04 23:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 8.3.0
Known to fail:
Last reconfirmed: 2019-05-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Stone 2019-05-10 23:22:28 UTC
The following code causes an internal compiler error:


struct empty {};

struct has_empty {
	[[no_unique_address]] empty brace_or_equal_initialized{};
};

struct has_value {
	int non_zero = 1;
};


struct pair : has_empty, has_value {};

pair a;
//pair b = pair();





<source>:14:7: internal compiler error: in output_constructor_regular_field, at varasm.c:5207

   14 | pair a;

      |       ^




See it live: https://godbolt.org/z/tvdsmg


The error occurs if you comment out a and uncomment b, as well. `brace_or_equal_initialized` can also be initialized by a regular constructor call, the important part is just that the constructor is explicitly called.
Comment 1 Richard Biener 2019-05-13 09:24:15 UTC
Confirmed.  GCC 8 ignores the attribute and works.
Comment 2 Marek Polacek 2019-05-13 15:36:15 UTC
Started with r268368.
Comment 3 Jakub Jelinek 2019-08-12 08:54:26 UTC
GCC 9.2 has been released.
Comment 4 GCC Commits 2020-03-04 22:33:28 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:6876b269bc7fe6465fedfed87c31e6175992129f

commit r10-7031-g6876b269bc7fe6465fedfed87c31e6175992129f
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Mar 4 12:08:42 2020 -0500

    c++: Fix [[no_unique_address]] and default mem-init [PR90432]
    
    output_constructor doesn't like two consecutive entries with fields at the
    same position; let's avoid adding the one for the empty field.
    
    gcc/cp/ChangeLog
    2020-03-04  Jason Merrill  <jason@redhat.com>
    
    	PR c++/90432
    	* init.c (perform_member_init): Don't do aggregate initialization of
    	empty field.
    	* constexpr.c (cx_check_missing_mem_inits): Don't enforce
    	initialization of empty field.
Comment 5 GCC Commits 2020-03-04 22:33:56 UTC
The releases/gcc-9 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

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

commit r9-8332-g9af9e004831f8efdfb68c2affea07b17fadd3279
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Mar 4 17:30:58 2020 -0500

    c++: Fix [[no_unique_address]] and default mem-init [PR90432]
    
    output_constructor doesn't like two consecutive entries with fields at the
    same position; let's avoid adding the one for the empty field.
    
    gcc/cp/ChangeLog
    2020-03-04  Jason Merrill  <jason@redhat.com>
    
    	PR c++/90432
    	* init.c (perform_member_init): Don't do aggregate initialization of
    	empty field.
    	* constexpr.c (cx_check_missing_mem_inits): Don't enforce
    	initialization of empty field.
Comment 6 Jason Merrill 2020-03-04 22:35:22 UTC
Fixed for 9.3/10.
Comment 7 Marek Polacek 2020-03-04 23:38:55 UTC
*** Bug 93898 has been marked as a duplicate of this bug. ***