Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspected implicit conversion errors #2232

Open
Ljiee opened this issue May 8, 2020 · 0 comments
Open

Suspected implicit conversion errors #2232

Ljiee opened this issue May 8, 2020 · 0 comments

Comments

@Ljiee
Copy link

Ljiee commented May 8, 2020

At line 524 and 526 of sqlite/src/func.c, clang10 complains that
"error: implicit conversion from 'long long' to 'double' changes value from 9223372036854775806 to 9223372036854775808
if( n==0 && r>=0 && r<LARGEST_INT64-1 ){ "
“error: implicit conversion from 'long long' to 'double' changes value from 9223372036854775806 to 9223372036854775808 }
else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){”

The source code is

 if( n==0 && r>=0 && r<LARGEST_INT64-1 ){
    r = (double)((sqlite_int64)(r+0.5));
  }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 )
    r = -(double)((sqlite_int64)((-r)+0.5));

if r is 9223372036854775806.9, there might be a risk of overflow.

In fact, SQLite has already changed its code, please reference mackyle/sqlite@26b1526.

Similarly, at line 264 of lua/ltypes.c, clang10 also reports a compilation error:
"error: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
dbl:if (darg < LLONG_MIN || darg > LLONG_MAX)".
The source code is

    dbl:if (darg < LLONG_MIN || darg > LLONG_MAX)
 265             luaL_error(lua, "conversion to: int failed from: %f", darg);
 266         *val= (long long) darg;
 267         return;

If darg is 9223372036854775807.5(could this happen?), there might be a risk of overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant