public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tim at klingt dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108309] New: ICE in in cxx_eval_component_reference, at cp/constexpr.cc:4136
Date: Fri, 06 Jan 2023 03:09:19 +0000	[thread overview]
Message-ID: <bug-108309-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108309
           Summary: ICE in in cxx_eval_component_reference, at
                    cp/constexpr.cc:4136
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tim at klingt dot org
  Target Milestone: ---

```
template <typename _Tp> constexpr _Tp forward(_Tp &__t) {
  return static_cast<_Tp &&>(__t);
}
struct _Enable_copy_move {};
struct optional;
template <int _Nm> struct __array_traits { typedef optional _Type[_Nm]; };
template <int _Nm> struct array { __array_traits<_Nm>::_Type _M_elems; };
struct _Optional_payload_base {
  union {
    int _M_value;
  };
};
struct _Optional_base {
  constexpr _Optional_base(...) : _M_payload() {}
  constexpr _Optional_base(_Optional_base &&) {}
  _Optional_payload_base _M_payload;
};
struct optional : _Optional_base, _Enable_copy_move {
  using _Base = _Optional_base;
  constexpr optional() {}
  template <typename _Up> constexpr optional(_Up __t) : _Base(forward(__t)) {}
} page {
  array<8> {}
}
```

gives me:

```
➜  scratch /usr/bin/g++-12 -std=gnu++20 testcase.ii
testcase.ii:24:1:   in ‘constexpr’ expansion of
‘page.optional::optional<array<8> >(array<8>{__array_traits<8>::_Type()})’
testcase.ii:24:1:   in ‘constexpr’ expansion of ‘forward(_Tp&) [with _Tp =
array<8>]()’
testcase.ii:24:1:   in ‘constexpr’ expansion of ‘array<8>((*
&((array<8>&&)__t)))’
testcase.ii:24:1:   in ‘constexpr’ expansion of
‘optional(<anonymous>.array<8>::_M_elems[0])’
testcase.ii:24:1: internal compiler error: in cxx_eval_component_reference, at
cp/constexpr.cc:4136
   24 | }
      | ^
0x7fb4eb429d8f __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7fb4eb429e3f __libc_start_main_impl
        ../csu/libc-start.c:392
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
```

with
```
g++-12 (Ubuntu 12.2.0-3ubuntu1~22.04) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

unfortunately cvise didn't reduce the test case to valid c++ code (afaict
there's only a missing semicolon, though). with a trailing semicolon, gcc-11
accepts the code, but clang++-15 doesn't (not sure if it's related, but i
thought it's worth mentioning:
```
testcase.reduced.cc:21:63: error: cannot pass object of non-trivial type
'array<8>' through variadic constructor; call will abort at runtime
[-Wnon-pod-varargs]
  template <typename _Up> constexpr optional(_Up __t) : _Base(forward(__t)) {}
                                                              ^
testcase.reduced.cc:22:3: note: in instantiation of function template
specialization 'optional::optional<array<8>>' requested here
} page {
  ^
1 error generated.
```

             reply	other threads:[~2023-01-06  3:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06  3:09 tim at klingt dot org [this message]
2023-01-06  3:09 ` [Bug c++/108309] " tim at klingt dot org
2023-01-06  6:22 ` [Bug c++/108309] [12 Regression] " pinskia at gcc dot gnu.org
2023-01-06  6:31 ` tim at klingt dot org
2023-01-06  6:33 ` pinskia at gcc dot gnu.org
2023-01-06 11:30 ` marxin at gcc dot gnu.org
2023-01-06 17:25 ` pinskia at gcc dot gnu.org
2023-04-27 12:06 ` rguenth at gcc dot gnu.org
2023-05-08 12:26 ` 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-108309-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).