public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "destructionator at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/110959] New: gdc: internal compiler error: in layout_aggregate_type in recursive templated class
Date: Wed, 09 Aug 2023 12:51:26 +0000	[thread overview]
Message-ID: <bug-110959-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110959
           Summary: gdc: internal compiler error: in layout_aggregate_type
                    in recursive templated class
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: destructionator at gmail dot com
  Target Milestone: ---

$ gdc --version
gdc (GCC) 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.



$ gdc gdcbug.d
gdcbug.d: In function ‘D main’:
gdcbug.d:40:23: internal compiler error: in layout_aggregate_type, at
d/types.cc:574
   40 |                 throw ArsdException!"Test"(4, "four");
      |                       ^
0x1bb6f56 internal_error(char const*, ...)
        ???:0
0x7a967a fancy_abort(char const*, int, char const*)
        ???:0
0x9bcb03 TypeVisitor::visit(TypeClass*)
        ???:0
0x9bb8c2 build_ctype(Type*)
        ???:0
0x9bc056 TypeVisitor::visit(TypeFunction*)
        ???:0
0x9bb8c2 build_ctype(Type*)
        ???:0
0x99fa34 get_decl_tree(Declaration*)
        ???:0
0x9a7e0c ExprVisitor::visit(VarExp*)
        ???:0
0x9a3b0f build_expr(Expression*, bool, bool)
        ???:0
0x9a5b13 ExprVisitor::visit(CallExp*)
        ???:0
0x9a3b0f build_expr(Expression*, bool, bool)
        ???:0
0x9a3bab build_expr_dtor(Expression*)
        ???:0
0x9b0250 IRVisitor::visit(ThrowStatement*)
        ???:0
0x9b0bc8 IRVisitor::visit(ScopeStatement*)
        ???:0
0x9b08c8 IRVisitor::visit(TryCatchStatement*)
        ???:0
0x9b016f IRVisitor::visit(CompoundStatement*)
        ???:0
0x9b016f IRVisitor::visit(CompoundStatement*)
        ???:0
0x9af85e build_function_body(FuncDeclaration*)
        ???:0
0x9a320a DeclVisitor::visit(FuncDeclaration*)
        ???:0
0x99d7c6 build_decl_tree(Dsymbol*)
        ???: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.






$ cat gdcbug.d
class ArsdExceptionBase : object.Exception {
        this(string operation, string file = __FILE__, size_t line = __LINE__,
Throwable next = null) {
                super(operation, file, line, next);
        }
}

template ArsdException(alias Type, DataTuple...) {
        static if(DataTuple.length)
                alias Parent = ArsdException!(Type, DataTuple[0 .. $-1]);
        else
                alias Parent = ArsdExceptionBase;

        class ArsdException : Parent {
                DataTuple data;

                this(DataTuple data, string file = __FILE__, size_t line =
__LINE__) {
                        this.data = data;
                        static if(is(Parent == ArsdExceptionBase))
                                super(null, file, line);
                        else
                                super(data[0 .. $-1], file, line);
                }

                static opCall(R...)(R r, string file = __FILE__, size_t line =
__LINE__) {
                        return new ArsdException!(Type, DataTuple, R)(r, file,
line);
                }
        }
}





Iain Buclaw notes the bug seems specific to 12.x, as the reproduction code
works well on gcc 13 and mainline.

/// This example shows how you can throw and catch the ad-hoc exception types.
void main() {
        // 0 or 1 args works
        try {
                throw ArsdException!"Test"(1);
        } catch(ArsdException!"Test" e) { // catch it without them
        }

        // 2 or more args causes ice
        try {
                throw ArsdException!"Test"(4, "four");
        } catch(ArsdException!("Test", int, string) e) { // catch it and use
info by specifying types
                assert(e.data[0] == 4); // and extract arguments like this
                assert(e.data[1] == "four");
        }
}

             reply	other threads:[~2023-08-09 12:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 12:51 destructionator at gmail dot com [this message]
2023-08-15 15:08 ` [Bug d/110959] " cvs-commit at gcc dot gnu.org
2023-08-15 15:17 ` cvs-commit at gcc dot gnu.org
2023-08-15 15:18 ` ibuclaw 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-110959-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).