Skip to content

Commit b517572

Browse files
allredjpeterschrammel
authored andcommitted
Correct return value test of to_integer (#508)
to_integer returns true in case of error. The contrary was assumed in convert_constant().
1 parent 933d841 commit b517572

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/java_bytecode/expr2java.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ std::string expr2javat::convert_constant(
215215
dest.reserve(char_representation_length);
216216

217217
mp_integer int_value;
218-
if(!to_integer(src, int_value))
218+
if(to_integer(src, int_value))
219219
assert(false);
220220

221221
dest+="(char)'";
@@ -238,7 +238,7 @@ std::string expr2javat::convert_constant(
238238
{
239239
// No byte-literals in Java, so just cast:
240240
mp_integer int_value;
241-
if(!to_integer(src, int_value))
241+
if(to_integer(src, int_value))
242242
assert(false);
243243
std::string dest="(byte)";
244244
dest+=integer2string(int_value);
@@ -248,7 +248,7 @@ std::string expr2javat::convert_constant(
248248
{
249249
// No short-literals in Java, so just cast:
250250
mp_integer int_value;
251-
if(!to_integer(src, int_value))
251+
if(to_integer(src, int_value))
252252
assert(false);
253253
std::string dest="(short)";
254254
dest+=integer2string(int_value);
@@ -258,7 +258,8 @@ std::string expr2javat::convert_constant(
258258
{
259259
// long integer literals must have 'L' at the end
260260
mp_integer int_value;
261-
to_integer(src, int_value);
261+
if(to_integer(src, int_value))
262+
assert(false);
262263
std::string dest=integer2string(int_value);
263264
dest+='L';
264265
return dest;

0 commit comments

Comments
 (0)