help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Some warnings with -Wconversion compiler flags


From: John W. Eaton
Subject: Some warnings with -Wconversion compiler flags
Date: Tue, 23 Sep 2008 15:59:45 -0400

On 23-Sep-2008, José Luis García Pallero wrote:

| Hello,
| Compiling an oct file with the -Wconversion warning flag appears some
| warnings messages. All warnings refers to functions contained in
| oct-inttypes.h. Are this warnings known? Are possible to fix it?

Does the following change help?

jwe

diff --git a/liboctave/oct-inttypes.h b/liboctave/oct-inttypes.h
--- a/liboctave/oct-inttypes.h
+++ b/liboctave/oct-inttypes.h
@@ -160,7 +160,7 @@
   { \
     bool out_of_range = x > static_cast<TC> (mx); \
     conv_flag |= (out_of_range ? math_truncate : 0); \
-    return out_of_range ? mx : x; \
+    return out_of_range ? mx : static_cast<T2> (x);  \
   }
 
 #define OCTAVE_US_S_FTR_FCNS(T) \
@@ -190,7 +190,7 @@
   { \
     bool out_of_range = x < 0; \
     conv_flag |= (out_of_range ? math_truncate : 0); \
-    return x <= 0 ? 0 : x; \
+    return x <= 0 ? static_cast<T2> (0) : static_cast<T2> (x); \
    }
 
 #define OCTAVE_S_US_FTR_FCNS(T) \

reply via email to

[Prev in Thread] Current Thread [Next in Thread]