public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/110959] New: gdc: internal compiler error: in layout_aggregate_type in recursive templated class
@ 2023-08-09 12:51 destructionator at gmail dot com
  2023-08-15 15:08 ` [Bug d/110959] " cvs-commit at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: destructionator at gmail dot com @ 2023-08-09 12:51 UTC (permalink / raw)
  To: gcc-bugs

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");
        }
}

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

* [Bug d/110959] gdc: internal compiler error: in layout_aggregate_type in recursive templated class
  2023-08-09 12:51 [Bug d/110959] New: gdc: internal compiler error: in layout_aggregate_type in recursive templated class destructionator at gmail dot com
@ 2023-08-15 15:08 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-15 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:3cf5a511e253876279462b1de08cfd8f5f804242

commit r12-9817-g3cf5a511e253876279462b1de08cfd8f5f804242
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Aug 15 16:56:42 2023 +0200

    d: Fix internal compiler error: in layout_aggregate_type, at d/types.cc:574

    This ICE is specific to the D front-end language version in GDC 12.

            PR d/110959

    gcc/d/ChangeLog:

            * dmd/canthrow.d (Dsymbol_canThrow): Use foreachVar.
            * dmd/declaration.d (TupleDeclaration::needThis): Likewise.
            (TupleDeclaration::foreachVar): New function.
            (VarDeclaration::setFieldOffset): Use foreachVar.
            * dmd/dinterpret.d (Interpreter::visit (DeclarationExp)): Likewise.
            * dmd/dsymbolsem.d (DsymbolSemanticVisitor::visit
(VarDeclaration)):
            Don't push tuple field members to the scope symbol table.
            (determineFields): Handle pushing tuple field members here instead.
            * dmd/dtoh.d (ToCppBuffer::visit (VarDeclaration)): Visit all tuple
            fields.
            (ToCppBuffer::visit (TupleDeclaration)): New function.
            * dmd/expression.d (expandAliasThisTuples): Use foreachVar.
            * dmd/foreachvar.d (VarWalker::visit (DeclarationExp)): Likewise.
            * dmd/ob.d (genKill): Likewise.
            (checkObErrors): Likewise.
            * dmd/semantic2.d (Semantic2Visitor::visit (TupleDeclaration)):
Visit
            all tuple fields.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr110959.d: New test.
            * gdc.test/runnable/test23010.d: New test.

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

* [Bug d/110959] gdc: internal compiler error: in layout_aggregate_type in recursive templated class
  2023-08-09 12:51 [Bug d/110959] New: gdc: internal compiler error: in layout_aggregate_type in recursive templated class destructionator at gmail dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-15 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:4acce4c4e53ae93ab8e7dad2ca9099e45559a541

commit r14-3225-g4acce4c4e53ae93ab8e7dad2ca9099e45559a541
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Aug 15 17:10:45 2023 +0200

    d: Add test case for PR110959.

    This ICE is specific to the D front-end language version in GDC 12,
    however a test has been added to mainline to catch the unlikely event of
    a regression.

            PR d/110959

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr110959.d: New test.

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

* [Bug d/110959] gdc: internal compiler error: in layout_aggregate_type in recursive templated class
  2023-08-09 12:51 [Bug d/110959] New: gdc: internal compiler error: in layout_aggregate_type in recursive templated class destructionator at gmail dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-08-15 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

ibuclaw at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |ibuclaw at gcc dot gnu.org

--- Comment #3 from ibuclaw at gcc dot gnu.org ---
Fix committed to releases/gcc-12, and test case added to mainline.

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

end of thread, other threads:[~2023-08-15 15:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 12:51 [Bug d/110959] New: gdc: internal compiler error: in layout_aggregate_type in recursive templated class destructionator at gmail dot com
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

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