public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer
@ 2014-11-26 16:25 maxim.yegorushkin at gmail dot com
  2014-12-08 16:52 ` [Bug c++/64085] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: maxim.yegorushkin at gmail dot com @ 2014-11-26 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

            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 
    #include <functional>
    #include <iostream>

    template<class T>
    auto make_monad(T&& arg) {
        return [captive = std::forward<T>(arg)](auto&& a) {
            std::cout << __PRETTY_FUNCTION__ << " " << a << '\n';
            return 1;
        };
    }

    template<class T>
    auto make_monad(std::reference_wrapper<T> arg) {
        return [&captive = arg.get()](auto&& a) {
            std::cout << __PRETTY_FUNCTION__ << " " << a << '\n';
            return 1;
        };
    }

    int main() {
        auto monad = [](auto&& captive) {
            return make_monad(std::forward<decltype(captive)>(captive));
        };

        int n = 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=native
-W{all,extra,init-self,cast-align,missing-include-dirs,pointer-arith}
-Werror={return-type,format,format-extra-args,reorder,uninitialized,narrowing}
-Wno-{missing-field-initializers,unused-local-typedefs}
-f{align-functions,diagnostics-show-option,message-length=0} -std=gnu++1y
-Wno-non-virtual-dtor -ftemplate-backtrace-limit=0 -g test.cc
Using built-in specs.
COLLECT_GCC=/usr/local/ots/7/bin/g++49
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.9.2-src/configure --prefix=/usr/local/ots/7
--program-suffix=49 --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --enable-checking=release --disable-multiarch
--disable-multilib --with-gmp-include=/usr/local/ots/7/include
--with-mpfr-include=/usr/local/ots/7/include
--with-mpc-include=/usr/local/ots/7/include
--with-cloog-include=/usr/local/ots/7/include
--with-isl-include=/usr/local/ots/7/include
--with-binutils-include=/usr/local/ots/7/include
--with-gmp-lib=/usr/local/ots/7/lib64 --with-mpfr-lib=/usr/local/ots/7/lib64
--with-mpc-lib=/usr/local/ots/7/lib64 --with-cloog-lib=/usr/local/ots/7/lib64
--with-isl-lib=/usr/local/ots/7/lib64
--with-binutils-lib=/usr/local/ots/7/lib64 --enable-languages=c,c++,fortran,lto
--enable-plugin --enable-initfini-array --enable-gold=default
--enable-libstdcxx-time --enable-linker-build-id --with-linker-hash-style=gnu
--disable-libgcj
Thread model: posix
gcc version 4.9.2 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'test.o' '-pthread' '-m64' '-march=native'
'-Wall' '-Wextra' '-Winit-self' '-Wcast-align' '-Wmissing-include-dirs'
'-Wpointer-arith' '-Werror=return-type' '-Werror=format'
'-Werror=format-extra-args' '-Werror=reorder' '-Werror=uninitialized'
'-Werror=narrowing' '-Wno-missing-field-initializers'
'-Wno-unused-local-typedefs' '-falign-functions' '-fdiagnostics-show-option'
'-fmessage-length=0' '-std=gnu++1y' '-Wno-non-virtual-dtor'
'-ftemplate-backtrace-limit=0' '-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_SOURCE
-D_REENTRANT test.cc -march=sandybridge -mmmx -mno-3dnow -msse -msse2 -msse3
-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-f16c
-mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt
-mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 --param
l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192
-mtune=sandybridge -quiet -dumpbase test.cc -m64 -auxbase-strip test.o -g -Wall
-Wextra -Winit-self -Wcast-align -Wmissing-include-dirs -Wpointer-arith
-Werror=return-type -Werror=format -Werror=format-extra-args -Werror=reorder
-Werror=uninitialized -Werror=narrowing -Wno-missing-field-initializers
-Wno-unused-local-typedefs -Wno-non-virtual-dtor -std=gnu++1y -version
-falign-functions -fdiagnostics-show-option -fmessage-length=0
-ftemplate-backtrace-limit=0 -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=100 --param ggc-min-heapsize=131072
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-fixed
 /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=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4745e1a90ce96a2734afd3f8df070d02
test.cc: In function ‘auto make_monad(std::reference_wrapper<_Tp>)’:
test.cc:14:36: internal compiler error: Segmentation fault
         return [&captive = 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 <http://gcc.gnu.org/bugs.html> 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: <gcc-bugs-return-468678-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.gnu.org>
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: <bug-64085-4-F3RKHYejFS@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64085-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64085-4@http.gcc.gnu.org/bugzilla/>
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?idd085

--- Comment #1 from Maxim Yegorushkin <maxim.yegorushkin at gmail dot com> ---
It compiles fine if I replace the line in question with:

        return [&captive = static_cast<T&>(arg)](auto&& a) {


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

* [Bug c++/64085] ICE on C++14 lambda by-reference capture with an initializer
  2014-11-26 16:25 [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer maxim.yegorushkin at gmail dot com
@ 2014-12-08 16:52 ` redi at gcc dot gnu.org
  2015-03-04 10:23 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-08 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed, but marking as a dup of PR64227 as that has a slightly simpler
reproducer.

*** This bug has been marked as a duplicate of bug 64227 ***


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

* [Bug c++/64085] ICE on C++14 lambda by-reference capture with an initializer
  2014-11-26 16:25 [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer maxim.yegorushkin at gmail dot com
  2014-12-08 16:52 ` [Bug c++/64085] " redi at gcc dot gnu.org
@ 2015-03-04 10:23 ` paolo.carlini at oracle dot com
  2015-03-04 17:42 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-04 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2015-03-04
         Resolution|DUPLICATE                   |---
     Ever confirmed|0                           |1

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This issue still exists.


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

* [Bug c++/64085] ICE on C++14 lambda by-reference capture with an initializer
  2014-11-26 16:25 [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer maxim.yegorushkin at gmail dot com
  2014-12-08 16:52 ` [Bug c++/64085] " redi at gcc dot gnu.org
  2015-03-04 10:23 ` paolo.carlini at oracle dot com
@ 2015-03-04 17:42 ` paolo.carlini at oracle dot com
  2015-04-03 17:24 ` paolo.carlini at oracle dot com
  2015-04-03 17:24 ` paolo at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-04 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is a reduced testcase:

template<typename T>
struct reference_wrapper
{
  T& get() const noexcept;
};

template<class T>
auto make_monad(reference_wrapper<T> arg) {
  return [&captive = arg.get()](auto&&) { return 1; };
}

int main()
{
  make_monad(reference_wrapper<int&>());
}


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

* [Bug c++/64085] ICE on C++14 lambda by-reference capture with an initializer
  2014-11-26 16:25 [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer maxim.yegorushkin at gmail dot com
                   ` (2 preceding siblings ...)
  2015-03-04 17:42 ` paolo.carlini at oracle dot com
@ 2015-04-03 17:24 ` paolo.carlini at oracle dot com
  2015-04-03 17:24 ` paolo at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-04-03 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org
   Target Milestone|---                         |5.0

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed.


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

* [Bug c++/64085] ICE on C++14 lambda by-reference capture with an initializer
  2014-11-26 16:25 [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer maxim.yegorushkin at gmail dot com
                   ` (3 preceding siblings ...)
  2015-04-03 17:24 ` paolo.carlini at oracle dot com
@ 2015-04-03 17:24 ` paolo at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-04-03 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Apr  3 17:23:27 2015
New Revision: 221858

URL: https://gcc.gnu.org/viewcvs?rev=221858&root=gcc&view=rev
Log:
/cp
2015-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/64085
    * lambda.c (add_capture): Use dependent_type_p for capture by
    reference too.

/testsuite
2015-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/64085
    * g++.dg/cpp1y/lambda-init13.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/lambda-init13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lambda.c
    trunk/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2015-04-03 17:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 16:25 [Bug c++/64085] New: ICE on C++14 lambda by-reference capture with an initializer maxim.yegorushkin at gmail dot com
2014-12-08 16:52 ` [Bug c++/64085] " redi at gcc dot gnu.org
2015-03-04 10:23 ` paolo.carlini at oracle dot com
2015-03-04 17:42 ` paolo.carlini at oracle dot com
2015-04-03 17:24 ` paolo.carlini at oracle dot com
2015-04-03 17:24 ` paolo 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).