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

implicit conversion from 'long long' to 'double' changes value #105

Open
ryandesign opened this issue Oct 1, 2023 · 0 comments
Open

implicit conversion from 'long long' to 'double' changes value #105

ryandesign opened this issue Oct 1, 2023 · 0 comments

Comments

@ryandesign
Copy link

I noticed that this warning occurs when building vmtouch 1.3.1 with llvm.org clang 12, 13, 14, 15, 16, 17:

vmtouch.c:318:13: warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion]
  if (val > INT64_MAX) fatal(errstr);
          ~ ^~~~~~~~~
/usr/include/stdint.h:122:26: note: expanded from macro 'INT64_MAX'
#define INT64_MAX        9223372036854775807LL
                         ^~~~~~~~~~~~~~~~~~~~~

On the next line you return (int64_t) val so maybe you want to cast val to int64_t for the INT64_MAX comparison too; that eliminates the warning:

--- vmtouch.c.orig	2018-11-16 08:40:02.000000000 -0600
+++ vmtouch.c	2023-10-01 17:34:40.000000000 -0500
@@ -315,7 +315,7 @@
 
   val *= mult;
 
-  if (val > INT64_MAX) fatal(errstr);
+  if ((int64_t) val > INT64_MAX) fatal(errstr);
 
   return (int64_t) val;
 }
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