diff options
author | Daniel Franke <franke@edf-online.de> | 2018-05-18 19:59:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-06-26 18:21:18 (GMT) |
commit | 8661e7052c4f711f13e7168231276e23c4c0defd (patch) | |
tree | eddefa9320ae82c187179b9e9664a9c12008e172 /Source/LexerParser/cmExprParser.y | |
parent | 7c4c13ffef87d748b896e2c762ad0b2c00afcd31 (diff) | |
download | CMake-8661e7052c4f711f13e7168231276e23c4c0defd.zip CMake-8661e7052c4f711f13e7168231276e23c4c0defd.tar.gz CMake-8661e7052c4f711f13e7168231276e23c4c0defd.tar.bz2 |
math: Diagnose divide-by-zero
Diffstat (limited to 'Source/LexerParser/cmExprParser.y')
-rw-r--r-- | Source/LexerParser/cmExprParser.y | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/LexerParser/cmExprParser.y b/Source/LexerParser/cmExprParser.y index 575ffa7..510daaa 100644 --- a/Source/LexerParser/cmExprParser.y +++ b/Source/LexerParser/cmExprParser.y @@ -18,6 +18,7 @@ Modify cmExprParser.cxx: #include <stdlib.h> #include <string.h> +#include <stdexcept> /*-------------------------------------------------------------------------*/ #define YYDEBUG 1 @@ -129,6 +130,9 @@ term: $<Number>$ = $<Number>1 * $<Number>3; } | term exp_DIVIDE unary { + if (yyvsp[0].Number == 0) { + throw std::overflow_error("divide by zero"); + } $<Number>$ = $<Number>1 / $<Number>3; } | term exp_MOD unary { |