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

            Bug ID: 78890
           Summary: [5/6/7 Regression] ICE on invalid reference type in
                    union
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: trippels at gcc dot gnu.org
  Target Milestone: ---

Reddit user sjd96 reported the following issue:

 % cat union.ii
int main() {
  union {
    int a;
    int &b = a;
  };
  a = 1;
  auto c = b + 1;
}

 % g++ -c union.ii
union.ii: In function ‘int main()’:
union.ii:1:5: error: invalid first operand of MEM_REF
 int main() {
     ^~~~
_2
union.ii:7:12: note: in statement
   auto c = b + 1;
            ^
_3 = MEM[(int &)_2];
union.ii:1:5: internal compiler error: verify_gimple failed
 int main() {
     ^~~~
0xda2bd5 verify_gimple_in_cfg(function*, bool)
        /home/markus/gcc/gcc/tree-cfg.c:5266
0xc85c06 execute_function_todo
        /home/markus/gcc/gcc/passes.c:1965
0xc86cab execute_todo
        /home/markus/gcc/gcc/passes.c:2015


 % g++ -std=c++98 -c union.ii
union.ii: In function ‘int main()’:
union.ii:4:14: warning: non-static data member initializers only available with
-std=c++11 or -std=gnu++11
     int &b = a;
              ^
union.ii:4:14: error: in C++98 ‘main()::<unnamed union>::b’ may not have
reference type ‘int&’ because it is a member of a union
union.ii:7:8: error: ‘c’ does not name a type
   auto c = b + 1;
        ^

Reply via email to