public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115178] New: false positive computed goto jump warning
@ 2024-05-21 16:05 foldy at rmki dot kfki.hu
  2024-05-21 16:45 ` [Bug c++/115178] " pinskia at gcc dot gnu.org
  2024-05-21 17:02 ` foldy at rmki dot kfki.hu
  0 siblings, 2 replies; 3+ messages in thread
From: foldy at rmki dot kfki.hu @ 2024-05-21 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115178
           Summary: false positive computed goto jump warning
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foldy at rmki dot kfki.hu
  Target Milestone: ---

> cat test.cc
int test(int i)
{
  int res=0;
  { const void* labels1[2]={&&l1, &&l2};
    goto *labels1[i&1];
    l1: res=1;
    l2: res=2;
  }
  { const void* labels2[2]={&&l3, &&l4};
    goto *labels2[i&1];
    l3: res=3;
    l4: res=4;
  }
  return res;
}

> g++-14 -c test.cc
test.cc: In function ‘int test(int)’:
test.cc:6:5: warning: jump to label ‘l1’
    6 |     l1: res=1;
      |     ^~
test.cc:10:22: note:   as a possible target of computed goto
   10 |     goto *labels2[i&1];
      |                      ^
test.cc:4:17: note:   skips initialization of ‘const void* labels1 [2]’
    4 |   { const void* labels1[2]={&&l1, &&l2};
      |                 ^~~~~~~
test.cc:7:5: warning: jump to label ‘l2’
    7 |     l2: res=2;
      |     ^~
test.cc:10:22: note:   as a possible target of computed goto
   10 |     goto *labels2[i&1];
      |                      ^
test.cc:4:17: note:   skips initialization of ‘const void* labels1 [2]’
    4 |   { const void* labels1[2]={&&l1, &&l2};
      |                 ^~~~~~~


l1/l2 are not possible targets from labels2

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

* [Bug c++/115178] false positive computed goto jump warning
  2024-05-21 16:05 [Bug c++/115178] New: false positive computed goto jump warning foldy at rmki dot kfki.hu
@ 2024-05-21 16:45 ` pinskia at gcc dot gnu.org
  2024-05-21 17:02 ` foldy at rmki dot kfki.hu
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-21 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So for this warning GCC does not keep track of what the possible values can be
done for the computed gotos. GCC thinks all labels which have their address can
be taken are targets for a computed goto as a simple way to implement this
warning (it is also done that way for the CFG later on too).

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

* [Bug c++/115178] false positive computed goto jump warning
  2024-05-21 16:05 [Bug c++/115178] New: false positive computed goto jump warning foldy at rmki dot kfki.hu
  2024-05-21 16:45 ` [Bug c++/115178] " pinskia at gcc dot gnu.org
@ 2024-05-21 17:02 ` foldy at rmki dot kfki.hu
  1 sibling, 0 replies; 3+ messages in thread
From: foldy at rmki dot kfki.hu @ 2024-05-21 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from foldy at rmki dot kfki.hu ---
OK, thanks.

I have millions of this warning in a huge generated file. How can I silence
this check? -Wno-jump-misses-init works for C only.

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

end of thread, other threads:[~2024-05-21 17:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-21 16:05 [Bug c++/115178] New: false positive computed goto jump warning foldy at rmki dot kfki.hu
2024-05-21 16:45 ` [Bug c++/115178] " pinskia at gcc dot gnu.org
2024-05-21 17:02 ` foldy at rmki dot kfki.hu

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