[m-rev.] diff: avoid C compiler warnings on Cygwin

Julien Fischer jfischer at opturion.com
Fri Feb 28 17:11:52 AEDT 2014


Branches: main, 14.01

Avoid some C compiler warnings on Cygwin.

library/int.m:
 	Avoid warnings about overflows in implicit constant conversions in the
 	implementations of {min,max}_int/0 on Cygwin.  The C compiler is
 	complaining about where we assign LONG_MIN or LLONG_MIN to a 32-bit
 	MR_Integer.  This only occurs in code branches that are dead when
 	MR_Integer is 32-bit, so the fix here is just to put in some explicit
 	casts.

Julien.

diff --git a/library/int.m b/library/int.m
index 3a86657..b174468 100644
--- a/library/int.m
+++ b/library/int.m
@@ -724,10 +724,10 @@ int.max_int = X :-
      if (sizeof(MR_Integer) == sizeof(int)) {
          Max = INT_MAX;
      } else if (sizeof(MR_Integer) == sizeof(long)) {
-        Max = LONG_MAX;
+        Max = (MR_Integer) LONG_MAX;
      #if defined(LLONG_MAX)
      } else if (sizeof(MR_Integer) == sizeof(long long)) {
-        Max = LLONG_MAX;
+        Max = (MR_Integer) LLONG_MAX;
      #endif
      } else {
          MR_fatal_error(""Unable to figure out max integer size"");
@@ -745,10 +745,10 @@ int.min_int = X :-
      if (sizeof(MR_Integer) == sizeof(int)) {
          Min = INT_MIN;
      } else if (sizeof(MR_Integer) == sizeof(long)) {
-        Min = LONG_MIN;
+        Min = (MR_Integer) LONG_MIN;
      #if defined(LLONG_MIN)
      } else if (sizeof(MR_Integer) == sizeof(long long)) {
-        Min = LLONG_MIN;
+        Min = (MR_Integer) LLONG_MIN;
      #endif
      } else {
          MR_fatal_error(""Unable to figure out min integer size"");



More information about the reviews mailing list