Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: fix wrong warning about overflow i...



details:   https://anonhg.NetBSD.org/src/rev/af8791f31bf6
branches:  trunk
changeset: 374234:af8791f31bf6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Apr 11 19:07:08 2023 +0000

description:
lint: fix wrong warning about overflow in floating constant expressions

diffstat:

 usr.bin/xlint/lint1/tree.c |  15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diffs (49 lines):

diff -r 34c56810fc96 -r af8791f31bf6 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Apr 11 19:02:19 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Apr 11 19:07:08 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.509 2023/04/11 19:02:19 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.510 2023/04/11 19:07:08 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.509 2023/04/11 19:02:19 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.510 2023/04/11 19:07:08 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1507,12 +1507,7 @@ floating_error_value(tspec_t t, ldbl_t l
                return lv < 0 ? -FLT_MAX : FLT_MAX;
        if (t == DOUBLE)
                return lv < 0 ? -DBL_MAX : DBL_MAX;
-
-       /* FIXME: Remove the '(double)' cast near 'isfinite'. */
-       /* FIXME: Inlining the variable 'max' produces a wrong warning. */
-       /* LINTED 248: floating-point constant out of range */
-       ldbl_t max = LDBL_MAX;
-       return lv < 0 ? -max : max;
+       return lv < 0 ? -LDBL_MAX : LDBL_MAX;
 }
 
 /*
@@ -1584,14 +1579,14 @@ fold_float(tnode_t *tn)
                lint_assert(/*CONSTCOND*/false);
        }
 
-       lint_assert(fpe != 0 || isnan((double)v->v_ldbl) == 0);
+       lint_assert(fpe != 0 || isnan(v->v_ldbl) == 0);
        if (is_complex(v->v_tspec)) {
                /*
                 * Don't warn, as lint doesn't model the imaginary part of
                 * complex numbers.
                 */
                fpe = 0;
-       } else if (fpe != 0 || isfinite((double)v->v_ldbl) == 0 ||
+       } else if (fpe != 0 || isfinite(v->v_ldbl) == 0 ||
            (t == FLOAT &&
             (v->v_ldbl > FLT_MAX || v->v_ldbl < -FLT_MAX)) ||
            (t == DOUBLE &&



Home | Main Index | Thread Index | Old Index