[Bug c++/110186] -Weffc++ does not recognize user defined constructor.

2023-06-09 Thread amir.ahmed.ansari at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110186

--- Comment #3 from Amir Ansari  ---
Sorry, it is warning about C::C() = default rather than B::B() = default;

[Bug c++/110186] -Weffc++ does not recognize user defined constructor.

2023-06-09 Thread amir.ahmed.ansari at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110186

--- Comment #2 from Amir Ansari  ---
The compiler is warning about B::B() = default. That is C++ 11. How can you say
it has not been updated for C++11?

Meyer's updated book has a slightly different name:

Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14

https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996/ref=sxin_11_mbs_w_global_sims?content-id=amzn1.sym.f6adc278-60fd-4516-8b02-0dbae28f44f1%3Aamzn1.sym.f6adc278-60fd-4516-8b02-0dbae28f44f1=2O08PJEXO1KA3_ct_cx=effective+c%2B%2B=effective+c%2B%2B_rd_i=1491903996_rd_r=2a95b35c-be52-4f57-9146-6e8f627019b9_rd_w=gW5r8_rd_wg=664iO_rd_p=f6adc278-60fd-4516-8b02-0dbae28f44f1_rd_r=AC6GTZ4RY51196JFRGDX=1686292780=effective+c%2B%2Caps%2C318=1-1-9e7645f9-2d19-4bff-863e-f6cdbe50f990

[Bug c++/110187] New: The compiler fails to warn about deleted constructor

2023-06-09 Thread amir.ahmed.ansari at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110187

Bug ID: 110187
   Summary: The compiler fails to warn about deleted constructor
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: amir.ahmed.ansari at outlook dot com
  Target Milestone: ---

Created attachment 55293
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55293=edit
Code to replicate the problem

Compile the attached code with the following flags:

-std=c++17 -Wall -pedantic -Wextra -Weffc++ -O3 -flto

The program compiles successfully. Now attempt to create an object of type B as

auto b = B{};

Now the compiler spits errors (see below). This is very confusing for an
ordinary user. It becomes worse if B has a second constructor that initializes
a and this second constructor is used everywhere. This can lurk in the codebase
undetected until somebody finally instantiates B with the default constructor.
And it gets even worse when B is passed as a template argument and the error is
generated deep within the template instantiation.

: In function 'int main()':
:17:16: error: use of deleted function 'B::B()'
   17 | auto b = B{};
  |^
:9:5: note: 'B::B()' is implicitly deleted because the default
definition would be ill-formed:
9 | B() = default;
  | ^
:9:5: error: no matching function for call to 'A::A()'
:3:5: note: candidate: 'A::A(int)'
3 | A(int) {}
  | ^
:3:5: note:   candidate expects 1 argument, 0 provided
:1:7: note: candidate: 'constexpr A::A(const A&)'
1 | class A
  |   ^
:1:7: note:   candidate expects 1 argument, 0 provided
:1:7: note: candidate: 'constexpr A::A(A&&)'
:1:7: note:   candidate expects 1 argument, 0 provided

[Bug c++/110186] New: -Weffc++ does not recognize user defined constructor.

2023-06-08 Thread amir.ahmed.ansari at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110186

Bug ID: 110186
   Summary: -Weffc++ does not recognize user defined constructor.
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: amir.ahmed.ansari at outlook dot com
  Target Milestone: ---

Created attachment 55292
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55292=edit
Code to replicate the problem

Compile the attached code with the following flags:

-std=c++17 -Wall -pedantic -Wextra -Weffc++ -O3 -flto

The following output is generated:

: In constructor 'C::C()':
:23:1: warning: 'C::a' should be initialized in the member
initialization list [-Weffc++]
   23 | C::C() = default;
  | ^
: In constructor 'D::D()':
:28:5: warning: 'D::a' should be initialized in the member
initialization list [-Weffc++]
   28 | D() {}
  | ^

The compiler fails to consider B() = default; as a user defined default
constructor and does not generate the warning to initialize a in the member
initialization list.

[Bug c++/106351] New: ICE in fold expression involving templatized lambda

2022-07-19 Thread amir.ahmed.ansari at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106351

Bug ID: 106351
   Summary: ICE in fold expression involving templatized lambda
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: amir.ahmed.ansari at outlook dot com
  Target Milestone: ---

The following code:

template 
struct C
{
void f()
{
(
[&, this]()
{
}.operator()(),
...
);
}
};

int main()
{
C{}.f();

return 0;
}

produces:

: In instantiation of 'void C::f() [with Args = {int}]':
:17:15:   required from here
:9:30: internal compiler error: in lookup_template_class_1, at
cp/pt.cc:10114
7 | [&, this]()
  | ~
8 | {
  | ~ 
9 | }.operator()(),
  | ~^
0x1ba65f9 internal_error(char const*, ...)
???:0
0x6fad32 fancy_abort(char const*, int, char const*)
???:0
0x87f6fd lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x875d31 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x881224 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
???:0
0x878889 instantiate_decl(tree_node*, bool, bool)
???:0
0x8936ab instantiate_pending_templates(int)
???:0
0x79c46d c_parse_final_cleanups()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
ASM generation compiler returned: 1