authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-22 16:40:48-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-22 16:40:48-04:00
log31b72da84a14cb3652b3b770ac64e367d021529b
treef8804107a67c9a40af2fffc06b01780cb849c95e
parent65b495af58bcd010b997d9036ee39808451ef76c
signaturelock-open Commit is signed but in an unrecognized format.

more info in assertion failures


2 files changed, 9 insertions(+), 10 deletions(-)

src/util.cpp+1-8
......@@ -18,17 +18,10 @@ void zig_panic(const char *format, ...) {
1818 vfprintf(stderr, format, ap);
1919 fflush(stderr);
2020 va_end(ap);
21 stage2_panic(nullptr, 0);
21 stage2_panic("", 0);
2222 abort();
2323}
2424
25void assert(bool ok) {
26 if (!ok) {
27 const char *msg = "Assertion failed. This is a bug in the Zig compiler.";
28 stage2_panic(msg, strlen(msg));
29 }
30}
31
3225uint32_t int_hash(int i) {
3326 return (uint32_t)(i % UINT32_MAX);
3427}
src/util.hpp+8-2
......@@ -43,15 +43,21 @@ ATTRIBUTE_NORETURN
4343ATTRIBUTE_PRINTF(1, 2)
4444void zig_panic(const char *format, ...);
4545
46static inline void zig_assert(bool ok, const char *file, int line, const char *func) {
47 if (!ok) {
48 zig_panic("Assertion failed at %s:%d in %s. This is a bug in the Zig compiler.", file, line, func);
49 }
50}
51
4652#ifdef _WIN32
4753#define __func__ __FUNCTION__
4854#endif
4955
50#define zig_unreachable() zig_panic("unreachable: %s:%s:%d", __FILE__, __func__, __LINE__)
56#define zig_unreachable() zig_panic("Unreachable at %s:%d in %s. This is a bug in the Zig compiler.", __FILE__, __LINE__, __func__)
5157
5258// Assertions in stage1 are always on, and they call zig @panic.
5359#undef assert
54void assert(bool ok);
60#define assert(ok) zig_assert(ok, __FILE__, __LINE__, __func__)
5561
5662#if defined(_MSC_VER)
5763static inline int clzll(unsigned long long mask) {