[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#976024: g++-10 crashes for bitpacked enum class



Package: g++-10
Version: 10.2.0-16
Severity: normal
Tags: upstream

Dear Maintainer,

* What led up to the situation?

Compiling the following code crashes g++-10:

    // g++-10 -std=c++2a -o /tmp/example.cpp.o -c example.cpp
    enum class MyEnumClass { A };
    struct MyClass {
        MyEnumClass foobar : 8 { MyEnumClass::A };
    };
    bool some_function(MyClass x)
    {
        switch (x.foobar) {
        case MyEnumClass::A:
            return false;
        }
    }

See at the bottom the exact invocation, error messages, and g++ version.

This bug is a regression: g++-9 does *not* crash when compiling the above code.

* What exactly did you do (or not do) that was effective (or
  ineffective)?

The enum-class, bit-packing, seemingly incomplete switch-case, non-constant
switch-argument, all seem to be necessary to trigger the bug.

* What was the outcome of this action?

Compiler crash (error message see below)

* What outcome did you expect instead?

Either a successful compilation, or a compilation error; but not a compiler
crash.


Full error message and versions:

$ /usr/bin/g++-10 -std=c++2a -o /tmp/example.cpp.o -c example.cpp
example.cpp: In function ‘bool some_function(MyClass)’:
example.cpp:6:6: error: type precision mismatch in switch statement
    6 | bool some_function(MyClass x)
      |      ^~~~~~~~~~~~~
switch (_1) <default: <D.2095>, case 0: <D.2092>>
example.cpp:6:6: internal compiler error: ‘verify_gimple’ failed
0x128422d verify_gimple_in_seq(gimple*)
        ../../src/gcc/tree-cfg.c:5144
0xf85436 gimplify_body(tree_node*, bool)
        ../../src/gcc/gimplify.c:14888
0xf856a3 gimplify_function_tree(tree_node*)
        ../../src/gcc/gimplify.c:14978
0xdbbe27 cgraph_node::analyze()
        ../../src/gcc/cgraphunit.c:670
0xdbee27 analyze_functions
        ../../src/gcc/cgraphunit.c:1227
0xdbf9f2 symbol_table::finalize_compilation_unit()
        ../../src/gcc/cgraphunit.c:2986
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.

$ /usr/bin/g++-10 --version
g++-10 (Debian 10.2.0-16) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ /usr/bin/g++-9 -std=c++2a -o /tmp/example.cpp.o -c example.cpp
example.cpp: In function ‘bool some_function(MyClass)’:
example.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-
type]
   12 | }
      | ^

$ /usr/bin/g++-9 --version
g++-9 (Debian 9.3.0-18) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux home 5.8.0-1-amd64 #1 SMP Debian 5.8.7-1 (2020-09-05) x86_64 GNU/Linux



-- System Information:
Debian Release: bullseye/sid
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.8.0-1-amd64 (SMP w/4 CPU threads)
Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages g++-10 depends on:
ii  gcc-10            10.2.0-16
ii  gcc-10-base       10.2.0-16
ii  libc6             2.31-4
ii  libgmp10          2:6.2.0+dfsg-6
ii  libisl22          0.22.1-1
ii  libmpc3           1.2.0-1
ii  libmpfr6          4.1.0-3
ii  libstdc++-10-dev  10.2.0-16
ii  libzstd1          1.4.5+dfsg-4
ii  zlib1g            1:1.2.11.dfsg-2

g++-10 recommends no packages.

Versions of packages g++-10 suggests:
pn  g++-10-multilib  <none>
pn  gcc-10-doc       <none>

-- no debconf information

Reply to: