[Bug c++/115178] false positive computed goto jump warning

2024-05-21 Thread foldy at rmki dot kfki.hu via 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.

[Bug c++/115178] New: false positive computed goto jump warning

2024-05-21 Thread foldy at rmki dot kfki.hu via 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]={&, &};
goto *labels1[i&1];
l1: res=1;
l2: res=2;
  }
  { const void* labels2[2]={&, &};
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]={&, &};
  | ^~~
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 are not possible targets from labels2

[Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new

2021-05-01 Thread foldy at rmki dot kfki.hu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370

Bug ID: 100370
   Summary: [11.1.0 regression] Incorrect warning for placement
new
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: foldy at rmki dot kfki.hu
  Target Milestone: ---

With g++ 11.1.0:

tmp> cat test.cc
#include 

int main()
{
  struct s1 { int iv[4]; };
  struct s2 { union { char* cp; int* ip; }; };

  s2 b;
  b.ip=new int[8];
  new (b.ip+4) s1;
}
tmp> g++ -c test.cc
test.cc: In function 'int main()':
test.cc:10:12: warning: placement new constructing an object of type
'main()::s1' and size '16' in a region of type 'main()::s2' and size '0'
[-Wplacement-new=]
   10 |   new (b.ip+4) s1;
  |^~
test.cc:8:6: note: at offset 16 from 'b' declared here
8 |   s2 b;
  |  ^

g++ 10.2.1 is OK.