Launchpad has imported 7 comments from the remote bug at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86953.
If you reply to an imported comment from within Launchpad, your comment will be sent to the remote bug automatically. Read more about Launchpad's inter-bugtracker facilities at https://help.launchpad.net/InterBugTracking. ------------------------------------------------------------------------ On 2018-08-14T16:36:54+00:00 Remi-ducceschi wrote: Created attachment 44538 preprocessed file of a small test case for the constexpr crash Hello, I've created a small test case that produces a compiler crash. You can find attached the preprocessed file (main.ii) made by running the following command, with `G++ 7.3.1 20180303 (Red Hat 7.3.1-5)` on a CentOS 7 (with the devtoolset-7 installed), but it seems to exist on the last version too (see https://wandbox.org/permlink/zGZWdHIrRNJKfh5Z): g++ -O3 -Wall -Wextra -o main -save-temps -v main.cpp I give at the end of the mail the output of the command. You can find a run on the last G++ version (9) here: https://wandbox.org/permlink/zGZWdHIrRNJKfh5Z ----------------------- Here is the code: #include <iostream> struct Bugged { double x; bool isfreex; bool isfreey; constexpr bool operator==(const Bugged& other) const noexcept { return (x == other.x) && (isfreex == other.isfreex) && (isfreey == other.isfreey); } }; int main () { std::cout << std::boolalpha << (Bugged{} == Bugged{}) << std::endl; return 0; } ----------------------- The bug only appears if I enable optimization (-02 or -O3), I guess constexpr optimization is not done otherwise. The problem occurs on the operator==(). The compiler crashes because it can't compute the result of the constexpr. Note that if I change the struct so it doesn't hold booleans, but double instead, or if I remove any of the parentheses term in the operator== function, it doesn't crash. Note that this code compiles on MSVC 2017 and on clang 6 (though it doesn't mean anything). I search for a similar bug report but didn't find anything, sorry if this is a duplicate. ----------------------- Below the output of the command: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC) COLLECT_GCC_OPTIONS='-O3' '-Wall' '-Wextra' '-o' 'main' '-save-temps' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/cc1plus -E -quiet -v -D_GNU_SOURCE main.cpp -mtune=generic -march=x86-64 -Wall -Wextra -O3 -fpch-preprocess -o main.ii ignoring nonexistent directory "/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include-fixed" ignoring nonexistent directory "/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../x86_64-redhat-linux/include" #include "..." search starts here: #include <...> search starts here: /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7 /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/x86_64-redhat-linux /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/backward /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include /usr/local/include /opt/rh/devtoolset-7/root/usr/include /usr/include End of search list. COLLECT_GCC_OPTIONS='-O3' '-Wall' '-Wextra' '-o' 'main' '-save-temps' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/cc1plus -fpreprocessed main.ii -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main -O3 -Wall -Wextra -version -o main.s GNU C++14 (GCC) version 7.3.1 20180303 (Red Hat 7.3.1-5) (x86_64-redhat-linux) compiled by GNU C version 7.3.1 20180303 (Red Hat 7.3.1-5), GMP version 6.0.0, MPFR version 3.1.1, MPC version 1.0.1, isl version isl-0.16.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++14 (GCC) version 7.3.1 20180303 (Red Hat 7.3.1-5) (x86_64-redhat-linux) compiled by GNU C version 7.3.1 20180303 (Red Hat 7.3.1-5), GMP version 6.0.0, MPFR version 3.1.1, MPC version 1.0.1, isl version isl-0.16.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: d120f4d100e8519a845aa191e71919b8 main.cpp: In function âint main()â: main.cpp:23:43: in constexpr expansion of âBugged{}.Bugged::operator==(Bugged{})â main.cpp:23:54: internal compiler error: in cxx_eval_bit_field_ref, at cp/constexpr.c:2565 std::cout << std::boolalpha << (Bugged{} == Bugged{}) << std::endl; ^ Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/ccVplEXc.out file, please attach this to your bugreport. Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/0 ------------------------------------------------------------------------ On 2018-08-14T16:38:22+00:00 Remi-ducceschi wrote: Created attachment 44539 Small test case Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/1 ------------------------------------------------------------------------ On 2018-08-14T16:46:52+00:00 Mpolacek wrote: Confirmed. G++ 5 compiles it fine. Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/2 ------------------------------------------------------------------------ On 2018-08-14T17:42:03+00:00 Mpolacek wrote: struct B { double x; bool isfreex; bool isfreey; constexpr bool operator==(const B& other) const noexcept { return (x == other.x) && (isfreex == other.isfreex) && (isfreey == other.isfreey); } constexpr bool operator!=(const B& other) const noexcept { return !(*this == other); } }; int main () { bool b = B{} == B{}; } Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/3 ------------------------------------------------------------------------ On 2018-08-14T17:46:05+00:00 Mpolacek wrote: Started with r230365 -- Merge C++ delayed folding branch.. Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/4 ------------------------------------------------------------------------ On 2018-08-24T15:25:55+00:00 Jakub-gcc wrote: Another reason why we badly need to finish PR81601. The constexpr evaluator really can't cope well with these BIT_FIELD_REFs, they read multiple fields at once, or could also read some uninitialized bits in between and mask them off, etc. So at minimum we'd need to disable these optimizations while folding constexpr declared functions and if the fields don't have INTEGRAL_TYPE or the bit field reference covers more than one field. Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/5 ------------------------------------------------------------------------ On 2018-10-26T10:13:46+00:00 Jakub-gcc wrote: GCC 6 branch is being closed Reply at: https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1791425/comments/9 ** Changed in: gcc-defaults Status: Unknown => Confirmed ** Changed in: gcc-defaults Importance: Unknown => Medium -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1791425 Title: Compiler error: constexpr with bitfields. To manage notifications about this bug go to: https://bugs.launchpad.net/gcc-defaults/+bug/1791425/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
