public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints?
@ 2021-09-03 19:35 jbglaw@lug-owl.de
  2021-09-03 19:59 ` [Bug tree-optimization/102196] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-09-03 19:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

            Bug ID: 102196
           Summary: -Wmaybe-uninitialized: Maybe generate helpful hints?
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbglaw@lug-owl.de
  Target Milestone: ---

Hi!

I don't know the code behind -Wmaybe-uninitialized, but maybe it's possible to
show the path GCC considered when emitting this message?

Right now, with Debian's "gcc-snapshot" compiler, I cannot successfully "make
all-gas" for the microblaze-elf and mcore-elf targets (with current binutils at
0b99a66053fa1e93a984f75a7a3d5343c74882fb) due to a maybe-uninitialized warning
in md_assemble() which is kind of unpleasant to find the possible way through
the assignment maze...

My personal impression is that usually, the maybe-uninitialized warnings are
quite helpful, but it's somewhat tedious to track them down. As I'm revamping
my toolchain testing efforts, these show up every now and then.

Thanks,
  Jan-Benedict

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/102196] -Wmaybe-uninitialized: Maybe generate helpful hints?
  2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
@ 2021-09-03 19:59 ` pinskia at gcc dot gnu.org
  2021-09-03 20:20 ` jbglaw@lug-owl.de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-03 19:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
          Component|middle-end                  |tree-optimization
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2021-09-03
           Keywords|                            |diagnostic

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
They should show the usage of the variable and where the declaration of the
variable is.
Can you show what output you get from compiling binutils?
Maybe even attach the preprocessed source.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/102196] -Wmaybe-uninitialized: Maybe generate helpful hints?
  2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
  2021-09-03 19:59 ` [Bug tree-optimization/102196] " pinskia at gcc dot gnu.org
@ 2021-09-03 20:20 ` jbglaw@lug-owl.de
  2021-09-03 20:34 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-09-03 20:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

--- Comment #2 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
Declaration and possibly uninitialized usage are shown. Ie for said Binutils, I
get these messages:

 microblaze-{elf,linux}
~~~~~~~~~~~~~~~~~~~~~~~~
[all 2021-09-03 18:17:30] depbase=`echo config/tc-microblaze.o | sed
's|[^/]*$|.deps/&|;s|\.o$||'`;\
[all 2021-09-03 18:17:30] /usr/lib/gcc-snapshot/bin/gcc -DHAVE_CONFIG_H -I. 
-I. -I. -I../bfd -I./config -I./../include -I./.. -I./../bfd
-DLOCALEDIR="\"/tmp/gas-microblaze-elf/share/locale\""  -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror
-Wwrite-strings -I./../zlib -g -O2   -MT config/tc-microblaze.o -MD -MP -MF
$depbase.Tpo -c -o config/tc-microblaze.o config/tc-microblaze.c &&\
[all 2021-09-03 18:17:30] mv -f $depbase.Tpo $depbase.Po
[all 2021-09-03 18:17:32] config/tc-microblaze.c: In function 'md_assemble':
[all 2021-09-03 18:17:32] config/tc-microblaze.c:1170:27: error: 'immed' may be
used uninitialized [-Werror=maybe-uninitialized]
[all 2021-09-03 18:17:32]  1170 |       if (immed != (immed % 32))
[all 2021-09-03 18:17:32]       |                    ~~~~~~~^~~~~
[all 2021-09-03 18:17:32] config/tc-microblaze.c:918:16: note: 'immed' declared
here
[all 2021-09-03 18:17:32]   918 |   unsigned int immed, temp;
[all 2021-09-03 18:17:32]       |                ^~~~~
[all 2021-09-03 18:17:32] config/tc-microblaze.c:1746:27: error: 'immed' may be
used uninitialized [-Werror=maybe-uninitialized]
[all 2021-09-03 18:17:32]  1746 |       if (immed != (immed % 32)) {
[all 2021-09-03 18:17:32]       |                    ~~~~~~~^~~~~
[all 2021-09-03 18:17:32] config/tc-microblaze.c:918:16: note: 'immed' declared
here
[all 2021-09-03 18:17:32]   918 |   unsigned int immed, temp;
[all 2021-09-03 18:17:32]       |                ^~~~~
[all 2021-09-03 18:17:32] cc1: all warnings being treated as errors
[all 2021-09-03 18:17:32] make[3]: *** [Makefile:1238: config/tc-microblaze.o]
Error 1


 mcore-elf
~~~~~~~~~~~
[all 2021-09-03 18:17:17] depbase=`echo config/tc-mcore.o | sed
's|[^/]*$|.deps/&|;s|\.o$||'`;\
[all 2021-09-03 18:17:17] /usr/lib/gcc-snapshot/bin/gcc -DHAVE_CONFIG_H -I. 
-I. -I. -I../bfd -I./config -I./../include -I./.. -I./../bfd
-DLOCALEDIR="\"/tmp/gas-mcore-elf/share/locale\""  -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -Wwrite-strings
-I./../zlib -g -O2   -MT config/tc-mcore.o -MD -MP -MF $depbase.Tpo -c -o
config/tc-mcore.o config/tc-mcore.c &&\
[all 2021-09-03 18:17:17] mv -f $depbase.Tpo $depbase.Po
[all 2021-09-03 18:17:19] config/tc-mcore.c: In function 'md_assemble':
[all 2021-09-03 18:17:19] config/tc-mcore.c:1599:9: error: 'output' may be used
uninitialized [-Werror=maybe-uninitialized]
[all 2021-09-03 18:17:19]  1599 |   output[0] = INST_BYTE0 (inst);
[all 2021-09-03 18:17:19]       |   ~~~~~~^~~
[all 2021-09-03 18:17:19] config/tc-mcore.c:855:10: note: 'output' declared
here
[all 2021-09-03 18:17:19]   855 |   char * output;
[all 2021-09-03 18:17:19]       |          ^~~~~~
[all 2021-09-03 18:17:19] config/tc-mcore.c:1599:9: error: 'output' may be used
uninitialized [-Werror=maybe-uninitialized]
[all 2021-09-03 18:17:19]  1599 |   output[0] = INST_BYTE0 (inst);
[all 2021-09-03 18:17:19]       |   ~~~~~~^~~
[all 2021-09-03 18:17:19] config/tc-mcore.c:855:10: note: 'output' declared
here
[all 2021-09-03 18:17:19]   855 |   char * output;
[all 2021-09-03 18:17:19]       |          ^~~~~~
[all 2021-09-03 18:17:19] config/tc-mcore.c:1599:9: error: 'output' may be used
uninitialized [-Werror=maybe-uninitialized]
[all 2021-09-03 18:17:19]  1599 |   output[0] = INST_BYTE0 (inst);
[all 2021-09-03 18:17:19]       |   ~~~~~~^~~
[all 2021-09-03 18:17:19] config/tc-mcore.c:855:10: note: 'output' declared
here
[all 2021-09-03 18:17:19]   855 |   char * output;
[all 2021-09-03 18:17:19]       |          ^~~~~~
[all 2021-09-03 18:17:20] cc1: all warnings being treated as errors
[all 2021-09-03 18:17:20] make[3]: *** [Makefile:1238: config/tc-mcore.o] Error
1


Unfortunately, the toolchain testing host isn't yet publically hosted, so it's
not yet IPv4-reachable... Once moved to the DC, I'll announce it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/102196] -Wmaybe-uninitialized: Maybe generate helpful hints?
  2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
  2021-09-03 19:59 ` [Bug tree-optimization/102196] " pinskia at gcc dot gnu.org
  2021-09-03 20:20 ` jbglaw@lug-owl.de
@ 2021-09-03 20:34 ` pinskia at gcc dot gnu.org
  2021-09-03 21:16 ` egallager at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-03 20:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
tc-microblaze.c case:

      if (exp.X_op != O_constant)
        as_warn (_("Symbol used as immediate for shift instruction"));
      else
        {
          output = frag_more (isize);
          immed = exp.X_add_number;
        }

      if (immed != (immed % 32))
        {
          as_warn (_("Shift value > 32. using <value %% 32>"));
          immed = immed % 32;
        }


Maybe we could print out the pathes which set it but I don't think that is
useful. Especially in this case it where it is just set a few lines above.



The next one there is the same:
      if (exp.X_op != O_constant) {
        as_warn(_("Symbol used as immediate for mbar instruction"));
      } else {
        output = frag_more (isize);
        immed = exp.X_add_number;
      }
      if (immed != (immed % 32)) {
        as_warn(_("Immediate value for mbar > 32. using <value %% 32>"));
        immed = immed % 32;
      }


config/tc-mcore.c is much more complex, there is a switch table and on some
pathes output variable is not set.

Showing the path in the case of tc-mcore.c is going to be problemantic and
might not actually show the correct thing always.

Note I do think you should file a binutils bug since those obvious bugs there.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/102196] -Wmaybe-uninitialized: Maybe generate helpful hints?
  2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
                   ` (2 preceding siblings ...)
  2021-09-03 20:34 ` pinskia at gcc dot gnu.org
@ 2021-09-03 21:16 ` egallager at gcc dot gnu.org
  2021-09-03 22:14 ` msebor at gcc dot gnu.org
  2021-09-04 14:44 ` jbglaw@lug-owl.de
  5 siblings, 0 replies; 7+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-09-03 21:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
What does the static analyzer say? It has its own warning for uninitialized
variables that ought to show the paths taken...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/102196] -Wmaybe-uninitialized: Maybe generate helpful hints?
  2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
                   ` (3 preceding siblings ...)
  2021-09-03 21:16 ` egallager at gcc dot gnu.org
@ 2021-09-03 22:14 ` msebor at gcc dot gnu.org
  2021-09-04 14:44 ` jbglaw@lug-owl.de
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-09-03 22:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
             Blocks|                            |24639
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Let me confirm this since it's along the lines of what I've been experimenting
with (i.e., printing notes with the conditionals).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/102196] -Wmaybe-uninitialized: Maybe generate helpful hints?
  2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
                   ` (4 preceding siblings ...)
  2021-09-03 22:14 ` msebor at gcc dot gnu.org
@ 2021-09-04 14:44 ` jbglaw@lug-owl.de
  5 siblings, 0 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-09-04 14:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102196

--- Comment #6 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
Calling the compiler again with just adding -fanalyzer doesn't add more
information to the output. Do I need to turn on extra warnings to enable static
analysis for access to possibly uninitialized variables?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-04 14:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 19:35 [Bug middle-end/102196] New: -Wmaybe-uninitialized: Maybe generate helpful hints? jbglaw@lug-owl.de
2021-09-03 19:59 ` [Bug tree-optimization/102196] " pinskia at gcc dot gnu.org
2021-09-03 20:20 ` jbglaw@lug-owl.de
2021-09-03 20:34 ` pinskia at gcc dot gnu.org
2021-09-03 21:16 ` egallager at gcc dot gnu.org
2021-09-03 22:14 ` msebor at gcc dot gnu.org
2021-09-04 14:44 ` jbglaw@lug-owl.de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).