Bug Summary

File:build/gcc/wide-int-print.cc
Warning:line 109, column 5
Value stored to 'buf' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-suse-linux -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name wide-int-print.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -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 -analyzer-config-compatibility-mode=true -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/gcc -resource-dir /usr/lib64/clang/15.0.7 -D IN_GCC -D HAVE_CONFIG_H -I . -I . -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/. -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../include -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libcpp/include -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libcody -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libdecnumber -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libdecnumber/bid -I ../libdecnumber -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libbacktrace -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/x86_64-suse-linux -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/15.0.7/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-narrowing -Wwrite-strings -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fdeprecated-macro -fdebug-compilation-dir=/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/gcc -ferror-limit 19 -fno-rtti -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=plist-html -analyzer-config silence-checkers=core.NullDereference -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /buildworker/marxinbox-gcc-clang-static-analyzer/objdir/clang-static-analyzer/2023-03-27-141847-20772-1/report-M5d6CI.plist -x c++ /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/wide-int-print.cc
1/* Printing operations with very long integers.
2 Copyright (C) 2012-2023 Free Software Foundation, Inc.
3 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 3, or (at your option) any
10later version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT
13ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24
25/*
26 * public printing routines.
27 */
28
29#define BLOCKS_NEEDED(PREC)(((PREC) + 64 - 1) / 64) \
30 (((PREC) + HOST_BITS_PER_WIDE_INT64 - 1) / HOST_BITS_PER_WIDE_INT64)
31
32void
33print_dec (const wide_int_ref &wi, char *buf, signop sgn)
34{
35 if (sgn == SIGNED)
36 print_decs (wi, buf);
37 else
38 print_decu (wi, buf);
39}
40
41void
42print_dec (const wide_int_ref &wi, FILE *file, signop sgn)
43{
44 if (sgn == SIGNED)
45 print_decs (wi, file);
46 else
47 print_decu (wi, file);
48}
49
50
51/* Try to print the signed self in decimal to BUF if the number fits
52 in a HWI. Other print in hex. */
53
54void
55print_decs (const wide_int_ref &wi, char *buf)
56{
57 if ((wi.get_precision () <= HOST_BITS_PER_WIDE_INT64)
58 || (wi.get_len () == 1))
59 {
60 if (wi::neg_p (wi))
61 sprintf (buf, "-" HOST_WIDE_INT_PRINT_UNSIGNED"%" "l" "u",
62 -(unsigned HOST_WIDE_INTlong) wi.to_shwi ());
63 else
64 sprintf (buf, HOST_WIDE_INT_PRINT_DEC"%" "l" "d", wi.to_shwi ());
65 }
66 else
67 print_hex (wi, buf);
68}
69
70/* Try to print the signed self in decimal to FILE if the number fits
71 in a HWI. Other print in hex. */
72
73void
74print_decs (const wide_int_ref &wi, FILE *file)
75{
76 char buf[WIDE_INT_PRINT_BUFFER_SIZE(((((64*(8)) + 64) / 64) * 64) / 4 + 4)];
77 print_decs (wi, buf);
78 fputs (buf, file);
79}
80
81/* Try to print the unsigned self in decimal to BUF if the number fits
82 in a HWI. Other print in hex. */
83
84void
85print_decu (const wide_int_ref &wi, char *buf)
86{
87 if ((wi.get_precision () <= HOST_BITS_PER_WIDE_INT64)
88 || (wi.get_len () == 1 && !wi::neg_p (wi)))
89 sprintf (buf, HOST_WIDE_INT_PRINT_UNSIGNED"%" "l" "u", wi.to_uhwi ());
90 else
91 print_hex (wi, buf);
92}
93
94/* Try to print the signed self in decimal to FILE if the number fits
95 in a HWI. Other print in hex. */
96
97void
98print_decu (const wide_int_ref &wi, FILE *file)
99{
100 char buf[WIDE_INT_PRINT_BUFFER_SIZE(((((64*(8)) + 64) / 64) * 64) / 4 + 4)];
101 print_decu (wi, buf);
102 fputs (buf, file);
103}
104
105void
106print_hex (const wide_int_ref &val, char *buf)
107{
108 if (val == 0)
109 buf += sprintf (buf, "0x0");
Value stored to 'buf' is never read
110 else
111 {
112 buf += sprintf (buf, "0x");
113 int start = ROUND_DOWN (val.get_precision (), HOST_BITS_PER_WIDE_INT)((val.get_precision ()) & ~((64) - 1));
114 int width = val.get_precision () - start;
115 bool first_p = true;
116 for (int i = start; i >= 0; i -= HOST_BITS_PER_WIDE_INT64)
117 {
118 unsigned HOST_WIDE_INTlong uhwi = wi::extract_uhwi (val, i, width);
119 if (!first_p)
120 buf += sprintf (buf, HOST_WIDE_INT_PRINT_PADDED_HEX"%016" "l" "x", uhwi);
121 else if (uhwi != 0)
122 {
123 buf += sprintf (buf, HOST_WIDE_INT_PRINT_HEX_PURE"%" "l" "x", uhwi);
124 first_p = false;
125 }
126 width = HOST_BITS_PER_WIDE_INT64;
127 }
128 }
129}
130
131/* Print one big hex number to FILE. Note that some assemblers may not
132 accept this for large modes. */
133void
134print_hex (const wide_int_ref &wi, FILE *file)
135{
136 char buf[WIDE_INT_PRINT_BUFFER_SIZE(((((64*(8)) + 64) / 64) * 64) / 4 + 4)];
137 print_hex (wi, buf);
138 fputs (buf, file);
139}
140