public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "przemekmirek at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/96517] New: ICE in is_this_parameter when accessing constexpr method of a field inside coroutine lambda (with optimization)
Date: Fri, 07 Aug 2020 08:56:46 +0000	[thread overview]
Message-ID: <bug-96517-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 96517
           Summary: ICE in is_this_parameter when accessing constexpr
                    method of a field inside coroutine lambda (with
                    optimization)
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: przemekmirek at gmail dot com
  Target Milestone: ---

Created attachment 49017
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49017&action=edit
preprocessed source

Compiling the following code with any level of optimization enabled (anything
except O0) causes gcc to exit with an ICE. I'm using GCC 10.2.0 from MSYS2
MinGW, however the same error occurs on any GCC > 10.0 available in Compiler
Explorer, including trunk. 

See https://godbolt.org/z/h7bjKG

I've been trying to reduce it to a less-specific example, the original code
failed when accessing std::optional. I don't think I can shorten it any
further. Making get() non-constexpr, making _data static, making coroutine a
member function instead of a lambda, all stop the error from appearing.

---

#include <coroutine>

struct coroutine {
    struct promise_type {
        coroutine get_return_object() { return {}; }
        void return_void() {}
        void unhandled_exception() {}
        auto initial_suspend() noexcept { return std::suspend_never{}; }
        auto final_suspend() noexcept { return std::suspend_never{}; }
    };
};

struct data {
    constexpr int get() { return 5; }
};

struct test {
    data _data;

    void foo() {
        [this]() -> coroutine {
            _data.get();
            co_return;
        };
    }
};

int main() {}

---

The full commandline and output is attached below:

$ g++ -v -std=c++20 -fcoroutines -O1 -save-temps main.cpp

Using built-in specs.
COLLECT_GCC=C:\msys64\mingw32\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../gcc-10.2.0/configure --prefix=/mingw32
--with-local-prefix=/mingw32/local --build=i686-w64-mingw32
--host=i686-w64-mingw32 --target=i686-w64-mingw32
--with-native-system-header-dir=/mingw32/i686-w64-mingw32/include
--libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686
--with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++
--enable-shared --enable-static --enable-libatomic --enable-threads=posix
--enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes
--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check
--enable-lto --enable-libgomp --disable-multilib --enable-checking=release
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --disable-plugin --with-libiconv --with-system-zlib
--with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32
--with-isl=/mingw32 --with-pkgversion='Rev1, Built by MSYS2 project'
--with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as
--with-gnu-ld --disable-sjlj-exceptions --with-dwarf2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Rev1, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-v' '-std=c++2a' '-fcoroutines' '-O1' '-save-temps'
'-shared-libgcc' '-mtune=generic' '-march=i686'
 C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/cc1plus.exe -E -quiet
-v -iprefix C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/
-D_REENTRANT main.cpp -mtune=generic -march=i686 -std=c++2a -fcoroutines -O1
-fpch-preprocess -o main.ii
ignoring duplicate directory
"C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include/c++/10.2.0"
ignoring duplicate directory
"C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include/c++/10.2.0/i686-w64-mingw32"
ignoring duplicate directory
"C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include/c++/10.2.0/backward"
ignoring duplicate directory
"C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/10.2.0/include"
ignoring nonexistent directory "D:/msys64/mingw32/include"
ignoring nonexistent directory "/mingw32/include"
ignoring duplicate directory
"C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/10.2.0/include-fixed"
ignoring duplicate directory
"C:/msys64/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory "D:/msys64/mingw32/i686-w64-mingw32/include"
#include "..." search starts here:
#include <...> search starts here:

C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include/c++/10.2.0

C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include/c++/10.2.0/i686-w64-mingw32

C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include/c++/10.2.0/backward
 C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/include
 C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../include
 C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/include-fixed

C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-std=c++2a' '-fcoroutines' '-O1' '-save-temps'
'-shared-libgcc' '-mtune=generic' '-march=i686'
 C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/cc1plus.exe
-fpreprocessed main.ii -quiet -dumpbase main.cpp -mtune=generic -march=i686
-auxbase main -O1 -std=c++2a -version -fcoroutines -o main.s
GNU C++17 (Rev1, Built by MSYS2 project) version 10.2.0 (i686-w64-mingw32)
        compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version
4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (Rev1, Built by MSYS2 project) version 10.2.0 (i686-w64-mingw32)
        compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version
4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: b383ad3e7b4fa535de44ee60f873a45a
main.cpp: In function 'void
test::foo()::<lambda()>::_ZZN4test3fooEvENKUlvE_clEv.actor(test::foo()::<lambda()>::_ZZN4test3fooEvENKUlvE_clEv.frame*)':
main.cpp:24:9: internal compiler error: in is_this_parameter, at
cp/semantics.c:10206
   24 |         };
      |         ^

main.cpp:24:9: internal compiler error: Aborted
g++.exe: internal compiler error: Aborted signal terminated program cc1plus

             reply	other threads:[~2020-08-07  8:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07  8:56 przemekmirek at gmail dot com [this message]
2021-09-30 15:50 ` [Bug c++/96517] " iains at gcc dot gnu.org
2021-10-21 20:46 ` iains at gcc dot gnu.org
2021-11-06 19:30 ` pinskia at gcc dot gnu.org
2021-12-17 16:55 ` cvs-commit at gcc dot gnu.org
2022-06-28 10:41 ` jakub at gcc dot gnu.org
2023-07-07  9:02 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96517-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).