gdc ice
Adam D Ruppe
destructionator at gmail.com
Wed Aug 9 11:48:41 UTC 2023
$ 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 {
package 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);
}
}
}
/// 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");
}
}
More information about the D.gnu
mailing list