Bug Summary

File:src/lib/libm/src/s_ilogb.c
Warning:line 45, column 30
The left operand of '!=' is a garbage value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name s_ilogb.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/lib/libm/obj -resource-dir /usr/local/lib/clang/13.0.0 -include namespace.h -I /usr/src/lib/libm/arch/amd64 -I /usr/src/lib/libm/src -I /usr/src/lib/libm/src/ld80 -I /usr/src/lib/libm/hidden -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/lib/libm/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/lib/libm/src/s_ilogb.c
1/* @(#)s_ilogb.c 5.1 93/09/24 */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12
13/* ilogb(double x)
14 * return the binary exponent of non-zero x
15 * ilogb(0) = FP_ILOGB0
16 * ilogb(NaN) = FP_ILOGBNAN (no signal is raised)
17 * ilogb(inf) = INT_MAX (no signal is raised)
18 */
19
20#include <float.h>
21#include <math.h>
22
23#include "math_private.h"
24
25int
26ilogb(double x)
27{
28 int32_t hx,lx,ix;
1
'lx' declared without an initial value
29
30 GET_HIGH_WORD(hx,x)do { ieee_double_shape_type gh_u; gh_u.value = (x); (hx) = gh_u
.parts.msw; } while (0)
;
2
Loop condition is false. Exiting loop
31 hx &= 0x7fffffff;
32 if(hx<0x00100000) {
3
Assuming 'hx' is >= 1048576
4
Taking false branch
33 GET_LOW_WORD(lx,x)do { ieee_double_shape_type gl_u; gl_u.value = (x); (lx) = gl_u
.parts.lsw; } while (0)
;
34 if((hx|lx)==0)
35 return FP_ILOGB0(-0x7fffffff); /* ilogb(0) = FP_ILOGB0 */
36 else /* subnormal x */
37 if(hx==0) {
38 for (ix = -1043; lx>0; lx<<=1) ix -=1;
39 } else {
40 for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
41 }
42 return ix;
43 }
44 else if (hx<0x7ff00000) return (hx>>20)-1023;
5
Assuming 'hx' is >= 2146435072
6
Taking false branch
45 else if (hx>0x7ff00000 || lx!=0) return FP_ILOGBNAN0x7fffffff;
7
Assuming 'hx' is <= 2146435072
8
The left operand of '!=' is a garbage value
46 else return INT_MAX0x7fffffff;
47}
48DEF_STD(ilogb)__asm__(".global " "ilogb" " ; " "ilogb" " = " "_libm_ilogb");
49LDBL_MAYBE_CLONE(ilogb)__asm("");