From ff3cdbc3a078de1d54c13737264ed62f77ff1f50 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 17 Apr 2019 15:58:20 -0400 Subject: stage1 assertions always on, and have stack traces --- src/util.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index 192d74e766..9a6a382993 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -10,17 +10,25 @@ #include #include "util.hpp" +#include "userland.h" void zig_panic(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); - fprintf(stderr, "\n"); fflush(stderr); va_end(ap); + stage2_panic(nullptr, 0); abort(); } +void assert(bool ok) { + if (!ok) { + const char *msg = "Assertion failed. This is a bug in the Zig compiler."; + stage2_panic(msg, strlen(msg)); + } +} + uint32_t int_hash(int i) { return (uint32_t)(i % UINT32_MAX); } -- cgit v1.2.3