[Bug c++/113582] New: incorrect warning about unused label

2024-01-24 Thread nmmm at nmmm dot nu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113582

Bug ID: 113582
   Summary: incorrect warning about unused label
   Product: gcc
   Version: 13.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nmmm at nmmm dot nu
  Target Milestone: ---

This code:

template
void do_something(){
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-label"

start:

if constexpr(B)
goto start;

#pragma GCC diagnostic pop
}

int main(){
do_something<0>();
}

Generates a warning:

warning: label ‘start’ defined but not used [-Wunused-label]

pragma GCC diagnostic did not work as well.

[Bug c++/113582] incorrect warning about unused label

2024-01-24 Thread nmmm at nmmm dot nu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113582

--- Comment #1 from Nikolay Mihaylov  ---
If you move the pragma outside the templated function, no warning is shown:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-label"

template
void do_something(){

start:

if constexpr(B)
goto start;

}

#pragma GCC diagnostic pop

[Bug c++/113687] New: -Warray-bounds is not emitted inside class method

2024-01-31 Thread nmmm at nmmm dot nu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113687

Bug ID: 113687
   Summary: -Warray-bounds is not emitted inside class method
   Product: gcc
   Version: 13.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nmmm at nmmm dot nu
  Target Milestone: ---

No warning -Warray-bounds is shown when code is inside class method, defined
inside the class body or outside if they are inline or constexpr.

struct S{
int p(){
int x[2] = {0, 0};

return x[3]; // no warning shown
}

static int ps(){
int x[2] = {0, 0};

return x[3]; // no warning shown
}

int ps2inl();
int ps2();
};

inline int S::ps2inl(){
int x[2] = {0, 0};

return x[3]; // no warning shown
}

int S::ps2(){
int x[2] = {0, 0};

return x[3]; // warning shown correctly
}

int f(){
int x[2] = {0, 0};

return x[3]; // warning shown correctly
}

int main(){
}

[Bug c++/115557] New: initializing reference property inside template context - error is not recognized

2024-06-20 Thread nmmm at nmmm dot nu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115557

Bug ID: 115557
   Summary: initializing reference property inside template
context - error is not recognized
   Product: gcc
   Version: 14.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nmmm at nmmm dot nu
  Target Milestone: ---

Following code compiles without error or warning.

B::A &a{ 4 }; - this should emit error.

clang catch this and error message is:
non-const lvalue reference to type 'A' cannot bind to an initializer list
temporary



struct A{
A(int){}
};

template
struct B{
B(A &a) : a(a){}

A &a{ 4 }; // this is wrong
};

int main(){
A a{ 5 };

B b(a);
}