public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
@ 2014-05-06 22:22 gunnar at gmx dot info
  2014-05-21 10:20 ` [Bug c++/61088] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gunnar at gmx dot info @ 2014-05-06 22:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61088

            Bug ID: 61088
           Summary: segfault with array of lambdas initialized with
                    initializer list that contains a lambda that captures
                    the array
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gunnar at gmx dot info

The following code produces a segfault:

#include <functional>

int main()
{
    std::function<void()> x[] = { 
        [x](){} 
    };
}

$ g++ -std=gnu++0x test13.cpp
test13.cpp: In function ‘int main()’:
test13.cpp:6:5: internal compiler error: Segmentation fault
   [x](){} 
     ^
Please submit a full bug report,
with preprocessed source if appropriate.

It compiles without error when:
  - x is captured by reference
  - x is not an array

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.2-15'
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Debian 4.8.2-15) 

GCC 4.7.3 fails too:
$ g++-4.7 -v
Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.3-11'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-gnu-unique-object --disable-libmudflap --enable-plugin
--with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i586
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Debian 4.7.3-11)
>From gcc-bugs-return-450730-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue May 06 22:27:35 2014
Return-Path: <gcc-bugs-return-450730-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26284 invoked by alias); 6 May 2014 22:27:35 -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 26268 invoked by uid 48); 6 May 2014 22:27:31 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61088] segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
Date: Tue, 06 May 2014 22: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.8.2
X-Bugzilla-Keywords: ice-on-invalid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: NEW
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: keywords bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-61088-4-38Y2eHS3nM@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61088-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61088-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-05/txt/msg00422.txt.bz2
Content-length: 609

http://gcc.gnu.org/bugzilla/show_bug.cgi?ida088

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-05-06
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It should fail to compile because 'x' has incomplete type at that point.


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

* [Bug c++/61088] segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
  2014-05-06 22:22 [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array gunnar at gmx dot info
@ 2014-05-21 10:20 ` paolo.carlini at oracle dot com
  2014-05-21 10:50 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-05-21 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
   Target Milestone|---                         |4.10.0

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Mine.


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

* [Bug c++/61088] segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
  2014-05-06 22:22 [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array gunnar at gmx dot info
  2014-05-21 10:20 ` [Bug c++/61088] " paolo.carlini at oracle dot com
@ 2014-05-21 10:50 ` paolo.carlini at oracle dot com
  2014-05-21 10:51 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-05-21 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
As testcase, this can do, I think:

void f()
{
  typedef void (X) ();
  X x[] = { [x](){} };  // { dg-error "incomplete" }
}

something even closer to the original one is of course welcome.


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

* [Bug c++/61088] segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
  2014-05-06 22:22 [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array gunnar at gmx dot info
  2014-05-21 10:20 ` [Bug c++/61088] " paolo.carlini at oracle dot com
  2014-05-21 10:50 ` paolo.carlini at oracle dot com
@ 2014-05-21 10:51 ` paolo.carlini at oracle dot com
  2014-05-22 22:29 ` paolo at gcc dot gnu.org
  2014-05-22 22:30 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-05-21 10:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I meant:

void f()
{
  typedef void (*X) ();
  X x[] = { [x](){} };  // { dg-error "incomplete" }
}


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

* [Bug c++/61088] segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
  2014-05-06 22:22 [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array gunnar at gmx dot info
                   ` (2 preceding siblings ...)
  2014-05-21 10:51 ` paolo.carlini at oracle dot com
@ 2014-05-22 22:29 ` paolo at gcc dot gnu.org
  2014-05-22 22:30 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2014-05-22 22:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Thu May 22 22:28:24 2014
New Revision: 210829

URL: http://gcc.gnu.org/viewcvs?rev=210829&root=gcc&view=rev
Log:
/cp
2014-05-22  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/61088
    * lambda.c (add_capture): Enforce that capture by value requires
    complete type.
    * typeck2.c (cxx_incomplete_type_inform): Early return if
    TYPE_MAIN_DECL is null.

/testsuite
2014-05-22  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/61088
    * g++.dg/cpp0x/lambda/lambda-ice13.C: New.
    * g++.dg/cpp0x/lambda/lambda-ice7.C: Adjust.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lambda.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C


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

* [Bug c++/61088] segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array
  2014-05-06 22:22 [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array gunnar at gmx dot info
                   ` (3 preceding siblings ...)
  2014-05-22 22:29 ` paolo at gcc dot gnu.org
@ 2014-05-22 22:30 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-05-22 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

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


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

end of thread, other threads:[~2014-05-22 22:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-06 22:22 [Bug c++/61088] New: segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array gunnar at gmx dot info
2014-05-21 10:20 ` [Bug c++/61088] " paolo.carlini at oracle dot com
2014-05-21 10:50 ` paolo.carlini at oracle dot com
2014-05-21 10:51 ` paolo.carlini at oracle dot com
2014-05-22 22:29 ` paolo at gcc dot gnu.org
2014-05-22 22:30 ` paolo.carlini at oracle dot com

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).