From 263596435f02b94ff8b2940584156cb6d56b6d43 Mon Sep 17 00:00:00 2001 From: Dicebot Date: Fri, 2 Sep 2016 20:40:48 +0300 Subject: [PATCH 1/3] Custom assert handler to point to bugzilla Makes it more obvious that any failed assertion is a compiler bug to be reported. --- src/mars.d | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/mars.d b/src/mars.d index 6a8b6e134354..f263b47e3c80 100644 --- a/src/mars.d +++ b/src/mars.d @@ -1574,6 +1574,7 @@ int main() { import core.memory; import core.runtime; + import core.exception; version (GC) { @@ -1604,6 +1605,24 @@ int main() dmd_coverSetMerge(true); } + assertHandler = (string file, size_t line, string msg) nothrow { + import ddmd.errors; + import core.stdc.stdio; + + fprintf(stderr, "Fatal failure on line %d in file '%s'", + line, file.ptr); + + if (msg.length) + fprintf(stderr, ": %s\n", msg.ptr); + else + fprintf(stderr, "\n"); + + fprintf(stderr, "This is a compiler bug, please report it via " ~ + "https://issues.dlang.org/enter_bug.cgi\n"); + + exit(EXIT_FAILURE); + }; + auto args = Runtime.cArgs(); return tryMain(args.argc, cast(const(char)**)args.argv); } From 92c143072622574dfbf3c6e1a11d9942870f2cd7 Mon Sep 17 00:00:00 2001 From: Dicebot Date: Sat, 3 Sep 2016 15:12:08 +0300 Subject: [PATCH 2/3] Mention bugzilla in backend assert handler --- src/backend/util2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/util2.c b/src/backend/util2.c index ba00a00ddc65..43b0e4d95236 100644 --- a/src/backend/util2.c +++ b/src/backend/util2.c @@ -54,6 +54,8 @@ void util_assert(const char *file, int line) { fflush(stdout); printf("Internal error: %s %d\n",file,line); + printf("This is a compiler bug, please report it via " + "https://issues.dlang.org/enter_bug.cgi\n"); err_exit(); #if __clang__ __builtin_unreachable(); From 027083f95e73e61d9f4e68421ffa3939b5a483cb Mon Sep 17 00:00:00 2001 From: Dicebot Date: Sat, 3 Sep 2016 15:23:03 +0300 Subject: [PATCH 3/3] Always use tassert.h instead of assert.h --- src/backend/aa.c | 4 +++- src/backend/divcoeff.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/aa.c b/src/backend/aa.c index d079deb8a5ee..9231b8813ace 100644 --- a/src/backend/aa.c +++ b/src/backend/aa.c @@ -11,11 +11,13 @@ #include #include #include -#include #include "tinfo.h" #include "aa.h" +static char __file__[] = __FILE__; /* for tassert.h */ +#include "tassert.h" + // Implementation of associative array // Auto-rehash and pre-allocate - Dave Fladebo diff --git a/src/backend/divcoeff.c b/src/backend/divcoeff.c index 0371c3d035a2..1fc62a008e02 100644 --- a/src/backend/divcoeff.c +++ b/src/backend/divcoeff.c @@ -11,7 +11,9 @@ Source: https://github.com/dlang/dmd/blob/master/src/backend/divcoeff.c */ #include -#include + +static char __file__[] = __FILE__; /* for tassert.h */ +#include "tassert.h" typedef unsigned long long ullong;