diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-08-14 08:37:12 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-08-14 09:43:19 +0200 |
commit | 5e6d6c684ed31879b6393c12f2f7ade6355643a7 (patch) | |
tree | fb9cf4762ddcd54132d146ccb6bd344a59bd8abe /idlc | |
parent | 65913c1f00c23bb94234bcb4eb1e9b2a4c5a925d (diff) |
Avoid -fsanitize=float-cast-overflow when converting to AstExprValue::u::byval
...which is nominally of type sal_uInt8 but is also allowed to take on negative
sal_Int8 values. After a recent change to CustomTarget_idlc/parser_test it now
caused
> idlc/source/astexpression.cxx:907:59: runtime error: -128 is outside the range of representable values of type 'unsigned char'
> #0 in coerce_value(AstExprValue*, ExprType) at idlc/source/astexpression.cxx:907:59
[...]
> "conversion.tests 1" expected SUCCESS, got 1 (256): FAILED!
Change-Id: I343d39fa0b728133e58858ba62ec8a0f344e8fdf
Reviewed-on: https://gerrit.libreoffice.org/77440
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'idlc')
-rw-r--r-- | idlc/source/astexpression.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 3da8db708d78..f9b0f08f0534 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -892,7 +892,7 @@ coerce_value(AstExprValue *ev, ExprType t) { return false; } - auto tmp = static_cast<unsigned char>(ev->u.fval); + auto tmp = static_cast<unsigned char>(static_cast<sal_Int32>(ev->u.fval)); ev->u.byval = tmp; ev->et = ET_byte; return true; @@ -904,7 +904,7 @@ coerce_value(AstExprValue *ev, ExprType t) { return false; } - auto tmp = static_cast<unsigned char>(ev->u.dval); + auto tmp = static_cast<unsigned char>(static_cast<sal_Int32>(ev->u.dval)); ev->u.byval = tmp; ev->et = ET_byte; return true; |