[Bug c++/99132] New: ICE in C++20 mode for constexpr not_null evaluation -- in cxx_eval_indirect_ref, at cp/constexpr.c:4905

bobmiller at nvidia dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 17 14:22:00 GMT 2021


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

            Bug ID: 99132
           Summary: ICE in C++20 mode for constexpr not_null evaluation
                    --  in cxx_eval_indirect_ref, at cp/constexpr.c:4905
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bobmiller at nvidia dot com
  Target Milestone: ---

Usage of gsl-lite::not_null can cause an internal compiler error.

Minimal online example: https://godbolt.org/z/Y8n93K
I also intend to report this to the gsl-lite maintainer, but I don't believe
their code should trigger an ICE regardless.

My system is x86-linux-amd64.

I confirmed in current trunk, commit hash
24bf79f1798ad1d64812709001d2d11cd3e6849f

The attached preprocessed output (a-test.ii) was built with the following
command:
g++-11 -v -save-temps --std=c++20 test.cpp

Full output:
--------------------------------------------------
Using built-in specs.
COLLECT_GCC=/home/bob/bin/g++-11
COLLECT_LTO_WRAPPER=/home/bob/libexec/gcc/x86_64-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc/configure -v --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/home/bob/
--enable-checking=release --enable-languages=c,c++ --disable-multilib
--program-suffix=-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210217 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/bob/libexec/gcc/x86_64-linux-gnu/11.0.0/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE /home/bob/test.cpp -mtune=generic -march=x86-64
-std=c++20 -fpch-preprocess -o a-test.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0

/home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/x86_64-linux-gnu

/home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/backward
 /home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/include
 /usr/local/include
 /home/bob/include
 /home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/bob/libexec/gcc/x86_64-linux-gnu/11.0.0/cc1plus -fpreprocessed a-test.ii
-quiet -dumpdir a- -dumpbase test.cpp -dumpbase-ext .cpp -mtune=generic
-march=x86-64 -std=c++20 -version -o a-test.s
GNU C++20 (GCC) version 11.0.0 20210217 (experimental) (x86_64-linux-gnu)
        compiled by GNU C version 11.0.0 20210216 (experimental), GMP version
6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++20 (GCC) version 11.0.0 20210217 (experimental) (x86_64-linux-gnu)
        compiled by GNU C version 11.0.0 20210216 (experimental), GMP version
6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4db0a130394a49defb276090de10ab74
/home/bob/test.cpp: In member function ‘virtual void
Source::attachSink(gsl::not_null<Sink*>)’:
/home/bob/test.cpp:15:13:   in ‘constexpr’ expansion of
‘sink.gsl::not_null<Sink*>::operator->()’
/home/bob/test.cpp:16:5: internal compionline example:
https://godbolt.org/z/Y8n93K
ler error: in cxx_eval_indirect_ref, at cp/constexpr.c:4905
   16 |     }
      |     ^
0x6649a2 cxx_eval_indirect_ref
        ../../gcc/gcc/cp/constexpr.c:4905
0x6649a2 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6362
0x6dfc1a cxx_eval_component_reference
        ../../gcc/gcc/cp/constexpr.c:3797
0x6dfc1a cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6538
0x6dfc1a cxx_eval_component_reference
        ../../gcc/gcc/cp/constexpr.c:3797
0x6dfc1a cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6538
0x6dfa23 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6634
0x6e8875 cxx_eval_binary_expression
        ../../gcc/gcc/cp/constexpr.c:3122
0x6df609 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6500
0x6e1889 cxx_eval_conditional_expression
        ../../gcc/gcc/cp/constexpr.c:3232
0x6e1889 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6581
0x6e04e0 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6309
0x6e003c cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6320
0x6e0c26 cxx_eval_statement_list
        ../../gcc/gcc/cp/constexpr.c:5712
0x6e0c26 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6777
0x6de835 cxx_eval_call_expression
        ../../gcc/gcc/cp/constexpr.c:2712
0x6dff56 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6142
0x6e1ce1 cxx_eval_indirect_ref
        ../../gcc/gcc/cp/constexpr.c:4880
0x6e1ce1 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6362
0x6dfa23 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6634
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
---------------------------------------------------


More information about the Gcc-bugs mailing list