public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101371] New: constexpr expansions trigger internal Compiler Error
@ 2021-07-08  5:44 warren_graeme at yahoo dot co.uk
  2021-07-08  7:42 ` [Bug c++/101371] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: warren_graeme at yahoo dot co.uk @ 2021-07-08  5:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101371
           Summary: constexpr expansions trigger internal Compiler Error
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: warren_graeme at yahoo dot co.uk
  Target Milestone: ---

Created attachment 51115
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51115&action=edit
preprocessed source code

Hello,

When attempting to compile a C++ function with gcc I have triggered an Internal
Compiler Error. I achieved this with the following commands:

g++-7 --std=c++17 -E init.cc > init.ii
g++-7 --std=c++17 -c init.ii



1) the peccant function (init.cc) follows:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <array>
#include <bitset>
using namespace std;

constexpr unsigned short N_citruss = 8;

enum class berry: unsigned{cran, straw, rasp, bil, black, huckle, elder,
goose};
constexpr berry operator++(berry& b, int) noexcept {
        return b = berry(static_cast<int>(b) + 1); }

struct berry_set_CX{
        bitset<8> bset;
        constexpr berry_set_CX(const bitset<8>& bits) noexcept: bset(bits) {}
        constexpr berry_set_CX(const char  bits) noexcept: bset(bits) {}
        constexpr berry_set_CX() noexcept : bset() {}
        constexpr berry_set_CX(const berry_set_CX& rhs) noexcept :
bset(rhs.bset) {}
};

struct bersets_by_citrus_CX{
        array<berry_set_CX, N_citruss> berrysets;
};

struct entree0_CX{
        bersets_by_citrus_CX passes;
        constexpr entree0_CX(const bersets_by_citrus_CX& bsbc) noexcept :
passes(bsbc) {}
};

struct berrybox_CX{
        constexpr entree0_CX make_entree() const noexcept {
                bersets_by_citrus_CX bsbc {};
                return entree0_CX(bsbc);
        }
        constexpr berrybox_CX(berry w, berry_set_CX hs) noexcept {}
};

void init() noexcept{
        const berry_set_CX fixed(bitset<8>(1));
        for (berry root_berry = berry::cran; root_berry <= berry::goose;
root_berry++){
                berrybox_CX nu_cs0(root_berry, fixed);
                const entree0_CX& pas = nu_cs0.make_entree();
        }
        return;
}
--------------------------------------------------------------------------

2) the preprocessed source file (init.ii) is attached;

3) the compiler version used (gcc -v output)  is:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/7/lto-wrapper
OFFLOAD_TARGET_NAMES=hsa:nvptx-none
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,ada,go
--enable-offload-targets=hsa,nvptx-none, --without-cuda-driver
--enable-checking=release --disable-werror
--with-gxx-include-dir=/usr/include/c++/7 --enable-ssp --disable-libssp
--disable-libvtv --disable-libcc1 --disable-plugin
--with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --enable-version-specific-runtime-libs
--with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex
--enable-gnu-indirect-function --program-suffix=-7 --without-system-libunwind
--enable-multilib --with-arch-32=x86-64 --with-tune=generic
--build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 7.5.0 (SUSE Linux) 

--------------------------------------------------------------------------

4) the compiler output is:

i+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
init.cc: In function ‘void init()’:
init.cc:40:46:   in constexpr expansion of ‘berrybox_CX::make_entree() const()’
init.cc:40:46:   in constexpr expansion of ‘entree0_CX(((const
bersets_by_citrus_CX&)(& bsbc)))’
init.cc:25:79:   in constexpr expansion of
‘((entree0_CX*)this)->entree0_CX::passes.bersets_by_citrus_CX::bersets_by_citrus_CX(bsbc)’
init.cc:19:8:   in constexpr expansion of
‘((bersets_by_citrus_CX*)this)->bersets_by_citrus_CX::berrysets.std::array<berry_set_CX,
8>::array(bersets_by_citrus_CX::berrysets)’
init.cc:40:46:   in constexpr expansion of
‘berry_set_CX(std::array<berry_set_CX, 8>::_M_elems[0])’
init.cc:40:46: internal compiler error: in cxx_eval_component_reference, at
cp/constexpr.c:2479
   const entree0_CX& pas = nu_cs0.make_entree();
                                              ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.opensuse.org/> for instructions.

--------------------------------------------------------------------------

Initially the program which incorporated this function was developed under
OpenSuse Leap 42.3 . The default compiler on that OS did not support the
constexpr functionality I needed, so I installed g++-7 and used that. The code,
including this function, compiled (and ran) correctly.

Later I upgraded to OpenSuse Leap 15.2, my present OS; and as I had not changed
my code I was not expecting trouble. But it fell over as described. I was
puzzled as I was using the 15.2 default compiler, namely  g++-7. 

However I see now that there has been more than one edition of gcc-7, so if I
had silently changed from an earlier to a later version, there could be changes
which trigger the ICE. Unfortunately I no longer have Leap 42.3 so have no
record of which edition of gcc-7 I used then. 

I have tried compiling with gccs -8, -9 and -10: they all produce the same
output as gcc-7 above, except with different line numbers in "constexpr.c".

Yours faithfully,

Graeme A. Warren

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

end of thread, other threads:[~2022-03-29  1:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08  5:44 [Bug c++/101371] New: constexpr expansions trigger internal Compiler Error warren_graeme at yahoo dot co.uk
2021-07-08  7:42 ` [Bug c++/101371] " rguenth at gcc dot gnu.org
2021-07-08 13:50 ` mpolacek at gcc dot gnu.org
2021-07-08 14:30 ` mpolacek at gcc dot gnu.org
2021-07-09  0:33 ` mpolacek at gcc dot gnu.org
2021-07-09  0:38 ` [Bug c++/101371] [9/10/11/12 Regression] " mpolacek at gcc dot gnu.org
2021-07-09  0:38 ` mpolacek at gcc dot gnu.org
2021-07-10  2:40 ` mpolacek at gcc dot gnu.org
2021-07-14 15:56 ` [Bug c++/101371] [9/10/11 " mpolacek at gcc dot gnu.org
2022-03-29  1:44 ` cvs-commit at gcc dot gnu.org
2022-03-29  1:47 ` [Bug c++/101371] [9/10 " mpolacek 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).