public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "johelegp at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106304] New: [modules] ICE compiling dynamic_cast in constexpr function (in tree_node, at cp/module.cc:9183)
Date: Thu, 14 Jul 2022 17:15:24 +0000	[thread overview]
Message-ID: <bug-106304-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106304
           Summary: [modules] ICE compiling dynamic_cast in constexpr
                    function (in tree_node, at cp/module.cc:9183)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/xz4Mhd8Wc, which Clang accepts:
https://godbolt.org/z/saachff5d.

mod.cpp:
```C++
export module mod;

template<class T> struct A : T {
  constexpr A(T v) : T{v} { }
  ~A() = default; // Fixes GCC.
};

struct B {
  virtual ~B() = default;
};

export inline constexpr auto x = A{B{}};

export constexpr const A<B>* y(const B& b) {
  return dynamic_cast<const A<B>*>(&b);
}
```

test.cpp:
```C++
import mod;
static_assert(&x == y(x));
int main() { }
```

Output:
```
[ 50%] Building CXX object CMakeFiles/mod.dir/mod.cpp.o
mod.cpp:1:8: internal compiler error: in tree_node, at cp/module.cc:9183
    1 | export module mod;
      |        ^~~~~~
0x221f229 internal_error(char const*, ...)
        ???:0
0x74c10d fancy_abort(char const*, int, char const*)
        ???:0
0x8fd00f trees_out::tree_node(tree_node*)
        ???:0
0x8fde5f trees_out::core_vals(tree_node*)
        ???:0
0x902d6d trees_out::tree_value(tree_node*)
        ???:0
0x8fcf41 trees_out::tree_node(tree_node*)
        ???:0
0x8fde5f trees_out::core_vals(tree_node*)
        ???:0
0x902d6d trees_out::tree_value(tree_node*)
        ???:0
0x8fcf41 trees_out::tree_node(tree_node*)
        ???:0
0x8fde5f trees_out::core_vals(tree_node*)
        ???:0
0x902d6d trees_out::tree_value(tree_node*)
        ???:0
0x8fcf41 trees_out::tree_node(tree_node*)
        ???:0
0x8fde5f trees_out::core_vals(tree_node*)
        ???:0
0x902d6d trees_out::tree_value(tree_node*)
        ???:0
0x8fcf41 trees_out::tree_node(tree_node*)
        ???:0
0x8fde5f trees_out::core_vals(tree_node*)
        ???:0
0x902d6d trees_out::tree_value(tree_node*)
        ???:0
0x8fcf41 trees_out::tree_node(tree_node*)
        ???:0
0x8fde5f trees_out::core_vals(tree_node*)
        ???:0
0x902d6d trees_out::tree_value(tree_node*)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

             reply	other threads:[~2022-07-14 17:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 17:15 johelegp at gmail dot com [this message]
2022-07-26 10:03 ` [Bug c++/106304] " redi at gcc dot gnu.org
2022-07-26 14:57 ` johelegp at gmail dot com
2022-10-14 13:07 ` cvs-commit at gcc dot gnu.org
2022-10-14 13:10 ` ppalka at gcc dot gnu.org
2022-10-14 13:22 ` ppalka 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-106304-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).