Skip to content

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

Description

@ryandesign

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;
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions