From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23411 invoked by alias); 26 Nov 2014 16:25:57 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23396 invoked by uid 48); 26 Nov 2014 16:25:52 -0000 From: "maxim.yegorushkin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer Date: Wed, 26 Nov 2014 16:25:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: maxim.yegorushkin at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg03149.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64085 Bug ID: 64085 Summary: ICE on C++14 lambda by-reference capture with an initializer Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: maxim.yegorushkin at gmail dot com $ cat test.cc=20 #include #include template auto make_monad(T&& arg) { return [captive =3D std::forward(arg)](auto&& a) { std::cout << __PRETTY_FUNCTION__ << " " << a << '\n'; return 1; }; } template auto make_monad(std::reference_wrapper arg) { return [&captive =3D arg.get()](auto&& a) { std::cout << __PRETTY_FUNCTION__ << " " << a << '\n'; return 1; }; } int main() { auto monad =3D [](auto&& captive) { return make_monad(std::forward(captive)); }; int n =3D 1; monad(1)(1); monad(n)(2); monad(std::ref(n))(3); } $ /usr/local/ots/7/bin/g++ -v -c -o test.o -pthread -m64 -march=3Dnative -W{all,extra,init-self,cast-align,missing-include-dirs,pointer-arith} -Werror=3D{return-type,format,format-extra-args,reorder,uninitialized,narro= wing} -Wno-{missing-field-initializers,unused-local-typedefs} -f{align-functions,diagnostics-show-option,message-length=3D0} -std=3Dgnu++= 1y -Wno-non-virtual-dtor -ftemplate-backtrace-limit=3D0 -g test.cc Using built-in specs. COLLECT_GCC=3D/usr/local/ots/7/bin/g++49 Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.9.2-src/configure --prefix=3D/usr/local/ots/7 --program-suffix=3D49 --disable-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit --enable-checking=3Drelease --disable-multiarch --disable-multilib --with-gmp-include=3D/usr/local/ots/7/include --with-mpfr-include=3D/usr/local/ots/7/include --with-mpc-include=3D/usr/local/ots/7/include --with-cloog-include=3D/usr/local/ots/7/include --with-isl-include=3D/usr/local/ots/7/include --with-binutils-include=3D/usr/local/ots/7/include --with-gmp-lib=3D/usr/local/ots/7/lib64 --with-mpfr-lib=3D/usr/local/ots/7/= lib64 --with-mpc-lib=3D/usr/local/ots/7/lib64 --with-cloog-lib=3D/usr/local/ots/7= /lib64 --with-isl-lib=3D/usr/local/ots/7/lib64 --with-binutils-lib=3D/usr/local/ots/7/lib64 --enable-languages=3Dc,c++,for= tran,lto --enable-plugin --enable-initfini-array --enable-gold=3Ddefault --enable-libstdcxx-time --enable-linker-build-id --with-linker-hash-style= =3Dgnu --disable-libgcj Thread model: posix gcc version 4.9.2 (GCC)=20 COLLECT_GCC_OPTIONS=3D'-v' '-c' '-o' 'test.o' '-pthread' '-m64' '-march=3Dn= ative' '-Wall' '-Wextra' '-Winit-self' '-Wcast-align' '-Wmissing-include-dirs' '-Wpointer-arith' '-Werror=3Dreturn-type' '-Werror=3Dformat' '-Werror=3Dformat-extra-args' '-Werror=3Dreorder' '-Werror=3Duninitialized' '-Werror=3Dnarrowing' '-Wno-missing-field-initializers' '-Wno-unused-local-typedefs' '-falign-functions' '-fdiagnostics-show-option' '-fmessage-length=3D0' '-std=3Dgnu++1y' '-Wno-non-virtual-dtor' '-ftemplate-backtrace-limit=3D0' '-g' '-shared-libgcc' /home/max/.ots/7/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/cc1plus -quiet -v -iprefix /home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/ -D_GNU_SOUR= CE -D_REENTRANT test.cc -march=3Dsandybridge -mmmx -mno-3dnow -msse -msse2 -ms= se3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -maes -mno-sha -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -= mavx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f1= 6c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 --p= aram l1-cache-size=3D32 --param l1-cache-line-size=3D64 --param l2-cache-size=3D= 8192 -mtune=3Dsandybridge -quiet -dumpbase test.cc -m64 -auxbase-strip test.o -g= -Wall -Wextra -Winit-self -Wcast-align -Wmissing-include-dirs -Wpointer-arith -Werror=3Dreturn-type -Werror=3Dformat -Werror=3Dformat-extra-args -Werror= =3Dreorder -Werror=3Duninitialized -Werror=3Dnarrowing -Wno-missing-field-initializers -Wno-unused-local-typedefs -Wno-non-virtual-dtor -std=3Dgnu++1y -version -falign-functions -fdiagnostics-show-option -fmessage-length=3D0 -ftemplate-backtrace-limit=3D0 -o /tmp/ccljVVdY.s GNU C++ (GCC) version 4.9.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.9.2, GMP version 4.3.2, MPFR version 2.4.2,= MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 ignoring nonexistent directory "/home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../..= /x86_64-unknown-linux-gnu/include" ignoring duplicate directory "/home/max/.ots/7/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9= .2/../../../../include/c++/4.9.2" ignoring duplicate directory "/home/max/.ots/7/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9= .2/../../../../include/c++/4.9.2/x86_64-unknown-linux-gnu" ignoring duplicate directory "/home/max/.ots/7/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9= .2/../../../../include/c++/4.9.2/backward" ignoring duplicate directory "/home/max/.ots/7/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9= .2/include" ignoring duplicate directory "/home/max/.ots/7/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9= .2/include-fixed" ignoring nonexistent directory "/home/max/.ots/7/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.9= .2/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../= include/c++/4.9.2 /home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../= include/c++/4.9.2/x86_64-unknown-linux-gnu /home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../= include/c++/4.9.2/backward /home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include /home/max/.ots/7/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include-fix= ed /usr/local/include /home/max/.ots/7/bin/../lib/gcc/../../include /usr/include End of search list. GNU C++ (GCC) version 4.9.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.9.2, GMP version 4.3.2, MPFR version 2.4.2,= MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: 4745e1a90ce96a2734afd3f8df070d02 test.cc: In function =E2=80=98auto make_monad(std::reference_wrapper<_Tp>)= =E2=80=99: test.cc:14:36: internal compiler error: Segmentation fault return [&captive =3D arg.get()](auto&& a) { ^ 0x98c36f crash_signal ../../gcc-4.9.2-src/gcc/toplev.c:337 0x644265 lvalue_kind(tree_node const*) ../../gcc-4.9.2-src/gcc/cp/tree.c:236 0x644468 real_lvalue_p(tree_node const*) ../../gcc-4.9.2-src/gcc/cp/tree.c:267 0x671672 add_capture(tree_node*, tree_node*, tree_node*, bool, bool) ../../gcc-4.9.2-src/gcc/cp/lambda.c:497 0x5df75d cp_parser_lambda_introducer ../../gcc-4.9.2-src/gcc/cp/parser.c:8999 0x5df75d cp_parser_lambda_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:8721 0x5df75d cp_parser_primary_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:4319 0x5e9a80 cp_parser_postfix_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:5971 0x5ec0f6 cp_parser_unary_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:7172 0x5ecd8f cp_parser_binary_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:7877 0x5ed241 cp_parser_assignment_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:8115 0x5ef32c cp_parser_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:8277 0x600104 cp_parser_expression ../../gcc-4.9.2-src/gcc/cp/parser.c:8316 0x600104 cp_parser_jump_statement ../../gcc-4.9.2-src/gcc/cp/parser.c:10710 0x600104 cp_parser_statement ../../gcc-4.9.2-src/gcc/cp/parser.c:9384 0x600769 cp_parser_statement_seq_opt ../../gcc-4.9.2-src/gcc/cp/parser.c:9772 0x6008a6 cp_parser_compound_statement ../../gcc-4.9.2-src/gcc/cp/parser.c:9726 0x6009e3 cp_parser_function_body ../../gcc-4.9.2-src/gcc/cp/parser.c:18766 0x6009e3 cp_parser_ctor_initializer_opt_and_function_body ../../gcc-4.9.2-src/gcc/cp/parser.c:18802 0x6016b2 cp_parser_function_definition_after_declarator ../../gcc-4.9.2-src/gcc/cp/parser.c:22927 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. >>From gcc-bugs-return-468678-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Nov 26 16:27:30 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 25397 invoked by alias); 26 Nov 2014 16:27:30 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 25369 invoked by uid 48); 26 Nov 2014 16:27:25 -0000 From: "maxim.yegorushkin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64085] ICE on C++14 lambda by-reference capture with an initializer Date: Wed, 26 Nov 2014 16:27:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: maxim.yegorushkin at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg03150.txt.bz2 Content-length: 251 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64085 --- Comment #1 from Maxim Yegorushkin --- It compiles fine if I replace the line in question with: return [&captive = static_cast(arg)](auto&& a) {