Module Name: src Committed By: rillig Date: Wed Apr 12 19:09:48 UTC 2023
Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: suppress warnings about LDBL_MAX in cross-build mode This fixes the cross build for sparc64 on x86_64, in which lint complained: warning: floating-point constant out of range [248] warning: floating point overflow on operator '-' [142] warning: floating-point constant out of range [248] To generate a diff of this commit: cvs rdiff -u -r1.511 -r1.512 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.511 src/usr.bin/xlint/lint1/tree.c:1.512 --- src/usr.bin/xlint/lint1/tree.c:1.511 Tue Apr 11 19:40:04 2023 +++ src/usr.bin/xlint/lint1/tree.c Wed Apr 12 19:09:48 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.511 2023/04/11 19:40:04 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.512 2023/04/12 19:09:48 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.511 2023/04/11 19:40:04 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.512 2023/04/12 19:09:48 rillig Exp $"); #endif #include <float.h> @@ -1507,7 +1507,23 @@ 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; - return lv < 0 ? -LDBL_MAX : LDBL_MAX; + /* + * When lint is compiled on x86_64 to check for sparc64, it uses the + * type 'long double' from x86_64, which is the Intel 80-bit format. + * The constant LDBL_MAX comes from the sparc64 preprocessor though + * and uses the IEEE-754-binary128 format, with the same exponent + * range but a wider mantissa. + * + * To properly handle this situation, lint would have to implement the + * floating-point types in a platform-independent way, which is not + * worth the effort, given how few programs practically use 'long + * double'. + * + * This caveat only affects cross builds. + */ + /* LINTED 248: floating-point constant out of range */ + ldbl_t max = LDBL_MAX; + return lv < 0 ? -max : max; } /*