public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
@ 2022-04-10 19:54 dcb314 at hotmail dot com
  2022-04-10 20:04 ` [Bug c/105210] " dcb314 at hotmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: dcb314 at hotmail dot com @ 2022-04-10 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105210
           Summary: gcc/auto-profile.cc:391:11: warning: variable 'level'
                    set but not used
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

A compile of recent gcc trunk with clang trunk shows
that local variable level is set but not used.

$ fgrep level ../trunk.git/gcc/auto-profile.cc
          level information (not source level). This info is used to help
     This will be enforced when instruction-level discriminator
        function is a top-level function_instance, i.e. it is the original copy
  /* For a given DECL, returns the top-level function_instance.  */
      int level = 0;
          level++;
/* For a given DECL, returns the top-level function_instance.  */
$ 

Suggest remove local variable.

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

* [Bug c/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
@ 2022-04-10 20:04 ` dcb314 at hotmail dot com
  2022-04-10 20:12 ` dcb314 at hotmail dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dcb314 at hotmail dot com @ 2022-04-10 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from David Binderman <dcb314 at hotmail dot com> ---
It would appear that clang trunk is better at finding set-but-not-used
variables than gcc.

Here are some more cases:

./../trunk.git/gcc/genautomata.cc:5664:7: warning: variable 'alts_number' set
but not used [-Wunused-but-set-variable]
../../trunk.git/gcc/graphite-poly.cc:344:7: warning: variable 'nb_reads' set
but not used [-Wunused-but-set-variable]
../../trunk.git/gcc/graphite-poly.cc:345:7: warning: variable 'nb_writes' set
but not used [-Wunused-but-set-variable]
../../trunk.git/gcc/lto-wrapper.cc:1428:12: warning: variable 'n_debugobj' set
but not used [-Wunused-but-set-variable]
../../trunk.git/libdecnumber/dpd/decimal64.c:617:8: warning: variable 'n' set
but not used [-Wunused-but-set-variable]
../../trunk.git/gcc/tree-switch-conversion.cc:2042:11: warning: variable
'ranges' set but not used [-Wunused-but-set-variable]

I am not sure if these variables are candidates for deletion, or some code
should be using them.

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

* [Bug c/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
  2022-04-10 20:04 ` [Bug c/105210] " dcb314 at hotmail dot com
@ 2022-04-10 20:12 ` dcb314 at hotmail dot com
  2022-04-10 21:58 ` [Bug gcov-profile/105210] " pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dcb314 at hotmail dot com @ 2022-04-10 20:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
It seems that recent gcc trunk can't detect set-but-not-used in this code:

extern int g( int);

void f( int m)
{
        int n;

        n = 0;

        for (int i = 0; i < m; ++i)
        {
                if (g( i))
                {
                        ++n;
                }
        }
}

$ /home/dcb/gcc/results/bin/g++ -c -g -O2  -Wall -Wextra -pedantic apr10b.cc
$

Recent clang trunk can:

$ /home/dcb/llvm/results/bin/clang++ -c -g -O2  -Wall  apr10b.cc
apr10b.cc:8:6: warning: variable 'n' set but not used
[-Wunused-but-set-variable]
        int n;
            ^
1 warning generated.
$

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
  2022-04-10 20:04 ` [Bug c/105210] " dcb314 at hotmail dot com
  2022-04-10 20:12 ` dcb314 at hotmail dot com
@ 2022-04-10 21:58 ` pinskia at gcc dot gnu.org
  2022-04-10 22:10 ` egallager at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-10 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |gcov-profile
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to David Binderman from comment #2)
> It seems that recent gcc trunk can't detect set-but-not-used in this code:

There is another bug about this already but I can't find that one right now; it
might have been closed as won't fix or invalid (I can't remember).

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2022-04-10 21:58 ` [Bug gcov-profile/105210] " pinskia at gcc dot gnu.org
@ 2022-04-10 22:10 ` egallager at gcc dot gnu.org
  2022-04-10 22:29 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-04-10 22:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=44677
           Keywords|                            |diagnostic
                 CC|                            |egallager at gcc dot gnu.org
             Blocks|                            |89180

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to David Binderman from comment #2)
> > It seems that recent gcc trunk can't detect set-but-not-used in this code:
> 
> There is another bug about this already but I can't find that one right now

bug 44677?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89180
[Bug 89180] [meta-bug] bogus/missing -Wunused warnings

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2022-04-10 22:10 ` egallager at gcc dot gnu.org
@ 2022-04-10 22:29 ` pinskia at gcc dot gnu.org
  2022-04-11  8:13 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-10 22:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #4)
> (In reply to Andrew Pinski from comment #3)
> > (In reply to David Binderman from comment #2)
> > > It seems that recent gcc trunk can't detect set-but-not-used in this code:
> > 
> > There is another bug about this already but I can't find that one right now
> 
> bug 44677?

Yes that one.

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2022-04-10 22:29 ` pinskia at gcc dot gnu.org
@ 2022-04-11  8:13 ` marxin at gcc dot gnu.org
  2022-04-11 14:24 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-11  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-04-11

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
I'm going to prepare a patch for next stage 1.

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2022-04-11  8:13 ` marxin at gcc dot gnu.org
@ 2022-04-11 14:24 ` marxin at gcc dot gnu.org
  2022-04-12 17:56 ` dcb314 at hotmail dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-11 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2022-04-11 14:24 ` marxin at gcc dot gnu.org
@ 2022-04-12 17:56 ` dcb314 at hotmail dot com
  2022-04-12 18:45 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dcb314 at hotmail dot com @ 2022-04-12 17:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Martin Liška from comment #6)
> I'm going to prepare a patch for next stage 1.

Do you mean the smaller patch to fix the problems I reported,
or a larger patch to have gcc duplicate the behaviour of clang ?

I checked the assembly language output from the code in comment 2
and AFAIK the optimiser removes the pointless increment at level -O1
and above.

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (7 preceding siblings ...)
  2022-04-12 17:56 ` dcb314 at hotmail dot com
@ 2022-04-12 18:45 ` marxin at gcc dot gnu.org
  2022-05-05 13:05 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-12 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
> Do you mean the smaller patch to fix the problems I reported,
> or a larger patch to have gcc duplicate the behaviour of clang ?

Yes, the former one.

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (8 preceding siblings ...)
  2022-04-12 18:45 ` marxin at gcc dot gnu.org
@ 2022-05-05 13:05 ` marxin at gcc dot gnu.org
  2022-05-05 15:43 ` dcb314 at hotmail dot com
  2022-05-05 18:31 ` marxin at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-05 13:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
Should be fixed with g:880456ed99d23ae76be4ecc929bcbcf8cae5eb66.

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (9 preceding siblings ...)
  2022-05-05 13:05 ` marxin at gcc dot gnu.org
@ 2022-05-05 15:43 ` dcb314 at hotmail dot com
  2022-05-05 18:31 ` marxin at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: dcb314 at hotmail dot com @ 2022-05-05 15:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Martin Liška from comment #9)
> Should be fixed with g:880456ed99d23ae76be4ecc929bcbcf8cae5eb66.

Presumably there's a good reason why the one in file
libdecnumber/dpd/decimal64.c
didn't get fixed ?

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

* [Bug gcov-profile/105210] gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used
  2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
                   ` (10 preceding siblings ...)
  2022-05-05 15:43 ` dcb314 at hotmail dot com
@ 2022-05-05 18:31 ` marxin at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-05 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> ---
> Presumably there's a good reason why the one in file
> libdecnumber/dpd/decimal64.c
> didn't get fixed ?

It's pretty legacy code out of gcc folder, so that's the reason ;)

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

end of thread, other threads:[~2022-05-05 18:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-10 19:54 [Bug c/105210] New: gcc/auto-profile.cc:391:11: warning: variable 'level' set but not used dcb314 at hotmail dot com
2022-04-10 20:04 ` [Bug c/105210] " dcb314 at hotmail dot com
2022-04-10 20:12 ` dcb314 at hotmail dot com
2022-04-10 21:58 ` [Bug gcov-profile/105210] " pinskia at gcc dot gnu.org
2022-04-10 22:10 ` egallager at gcc dot gnu.org
2022-04-10 22:29 ` pinskia at gcc dot gnu.org
2022-04-11  8:13 ` marxin at gcc dot gnu.org
2022-04-11 14:24 ` marxin at gcc dot gnu.org
2022-04-12 17:56 ` dcb314 at hotmail dot com
2022-04-12 18:45 ` marxin at gcc dot gnu.org
2022-05-05 13:05 ` marxin at gcc dot gnu.org
2022-05-05 15:43 ` dcb314 at hotmail dot com
2022-05-05 18:31 ` marxin at gcc dot gnu.org

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).