parent
309b4d8501
commit
89df134fed
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "mathlib.h"
|
||||
#include "errortypes.h"
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
template<class T>
|
||||
|
@ -62,14 +63,14 @@ R calculate(const std::string& s, const T& x, const T& y, bool* error = nullptr)
|
|||
case '*':
|
||||
return wrap(x * y);
|
||||
case '/':
|
||||
if (isZero(y)) {
|
||||
if (isZero(y) || (std::is_integral<T>{} && std::is_signed<T>{} && isEqual(y, T(-1)) && isEqual(x, std::numeric_limits<T>::min()))) {
|
||||
if (error)
|
||||
*error = true;
|
||||
return R{};
|
||||
}
|
||||
return wrap(x / y);
|
||||
case '%':
|
||||
if (isZero(MathLib::bigint(y))) {
|
||||
if (isZero(MathLib::bigint(y)) || (std::is_integral<T>{} && std::is_signed<T>{} && isEqual(y, T(-1)) && isEqual(x, std::numeric_limits<T>::min()))) {
|
||||
if (error)
|
||||
*error = true;
|
||||
return R{};
|
||||
|
|
|
@ -911,6 +911,8 @@ private:
|
|||
ASSERT(tokenValues(";-1>>10;",">>").empty());
|
||||
ASSERT(tokenValues(";10>>-1;",">>").empty());
|
||||
ASSERT(tokenValues(";10>>64;",">>").empty());
|
||||
ASSERT(tokenValues(";((-1) * 9223372036854775807LL - 1) / (-1);", "/").empty()); // #12109
|
||||
ASSERT_EQUALS(tokenValues(";((-1) * 9223372036854775807LL - 1) % (-1);", "%").size(), 1);
|
||||
|
||||
code = "float f(const uint16_t& value) {\n"
|
||||
" const uint16_t uVal = value; \n"
|
||||
|
|
Loading…
Reference in New Issue