diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-01-20 00:12:16 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-01-20 00:18:39 +0100 |
commit | c11b79ce51ad1c52e2c2e2700fcaff35b851bc97 (patch) | |
tree | 9617b7eae286be12ac243cb4e5d06bdfe0522abd /src/nvim/assert.h | |
parent | dbba685c697d31fcb7ece6d7435989dbccc71866 (diff) | |
download | rneovim-c11b79ce51ad1c52e2c2e2700fcaff35b851bc97.tar.gz rneovim-c11b79ce51ad1c52e2c2e2700fcaff35b851bc97.tar.bz2 rneovim-c11b79ce51ad1c52e2c2e2700fcaff35b851bc97.zip |
STRICT_ADD, STRICT_SUB: Log error before abort
Diffstat (limited to 'src/nvim/assert.h')
-rw-r--r-- | src/nvim/assert.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/nvim/assert.h b/src/nvim/assert.h index f3a5c71341..db21bed0e2 100644 --- a/src/nvim/assert.h +++ b/src/nvim/assert.h @@ -137,7 +137,12 @@ /// Not used if compiler supports __builtin_add_overflow. #ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_ADD(a, b, c, t) \ - do { if (__builtin_add_overflow(a, b, c)) { abort(); } } while (0) + do { \ + if (__builtin_add_overflow(a, b, c)) { \ + ELOG("STRICT_ADD overflow"); \ + abort(); \ + } \ + } while (0) #else # define STRICT_ADD(a, b, c, t) \ do { *(c) = (t)(a + b); } while (0) @@ -147,7 +152,12 @@ /// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow. #ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_SUB(a, b, c, t) \ - do { if (__builtin_sub_overflow(a, b, c)) { abort(); } } while (0) + do { \ + if (__builtin_sub_overflow(a, b, c)) { \ + ELOG("STRICT_SUB overflow"); \ + abort(); \ + } \ + } while (0) #else # define STRICT_SUB(a, b, c, t) \ do { *(c) = (t)(a - b); } while (0) |