This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80194] New: ICE with local constant referenced by a lambda expression


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

            Bug ID: 80194
           Summary: ICE with local constant referenced by a lambda
                    expression
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: curlypaul924 at gmail dot com
  Target Milestone: ---

The following causes an ICE on g++ 5.4.0 and on the latest gcc-5-branch.  It
does not ICE on 6.0 or later.

int fn1();

template <class Fn> void fn2(Fn &&fn) {
  fn(42);
}

void fn2() {
  auto const x = fn1();
  fn2([&](auto) { x; });
}

Building with -std=c++14, the output is:

test.cpp: In instantiation of ‘fn2()::<lambda(auto:1)> [with auto:1 = int]’:
test.cpp:4:5:   required from ‘void fn2(Fn&&) [with Fn =
fn2()::<lambda(auto:1)>]’
test.cpp:9:23:   required from here
test.cpp:9:19: internal compiler error: Segmentation fault
   fn2([&](auto) { x; });
                   ^
0xaab7ff crash_signal
        ../.././gcc/toplev.c:383
0x70ac4c maybe_constant_init(tree_node*, tree_node*)
        ../.././gcc/cp/constexpr.c:4097
0x6320bf tsubst_copy
        ../.././gcc/cp/pt.c:13180
0x622c68 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../.././gcc/cp/pt.c:15797
0x62b392 tsubst_expr
        ../.././gcc/cp/pt.c:14606
0x62a4f6 tsubst_expr
        ../.././gcc/cp/pt.c:14017
0x62b2dc tsubst_expr
        ../.././gcc/cp/pt.c:14189
0x62b2dc tsubst_expr
        ../.././gcc/cp/pt.c:14189
0x62a09d instantiate_decl(tree_node*, int, bool)
        ../.././gcc/cp/pt.c:20675
0x6597d2 mark_used(tree_node*, int)
        ../.././gcc/cp/decl2.c:5122
0x5f889b build_over_call
        ../.././gcc/cp/call.c:7545
0x5fafd1 build_op_call_1
        ../.././gcc/cp/call.c:4347
0x5fafd1 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ../.././gcc/cp/call.c:4370
0x6c3118 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ../.././gcc/cp/semantics.c:2426
0x624d46 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../.././gcc/cp/pt.c:15434
0x62b392 tsubst_expr
        ../.././gcc/cp/pt.c:14606
0x62a4f6 tsubst_expr
        ../.././gcc/cp/pt.c:14017
0x62b2dc tsubst_expr
        ../.././gcc/cp/pt.c:14189
0x62a09d instantiate_decl(tree_node*, int, bool)
        ../.././gcc/cp/pt.c:20675
0x63edeb instantiate_pending_templates(int)
        ../.././gcc/cp/pt.c:20792
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Output of g++ -v:

Using built-in specs.
COLLECT_GCC=/home/pbrannan/opt/gcc-5-branch/bin/g++
COLLECT_LTO_WRAPPER=/home/pbrannan/opt/gcc-5-branch/libexec/gcc/x86_64-unknown-linux-gnu/5.4.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --disable-multilib
--prefix=/home/pbrannan/opt/gcc-5-branch : (reconfigured) ./configure
--disable-multilib --prefix=/home/pbrannan/opt/gcc-5-branch
--enable-languages=c,c++,fortran,java,lto,objc --no-create --no-recursion
Thread model: posix
gcc version 5.4.1 20170326 (GCC)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]