[Bug c++/104995] New: access checking for function pointer template parameters takes place at call site
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104995 Bug ID: 104995 Summary: access checking for function pointer template parameters takes place at call site Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mawww at kakoune dot org Target Milestone: --- The following code ``` template void func() { auto lambda = [&](auto&& s) { F(s); }; lambda(0); } struct S { void f() { func(); } private: static void g(int) {} }; ``` Fails to compile on g++ 11.2.1 with the following error: ``` test.cc: In instantiation of ‘func():: [with auto:1 = int]’: test.cc:4:11: required from ‘void func() [with auto F = S::g]’ test.cc:8:26: required from here test.cc:3:36: error: ‘static void S::g(int)’ is private within this context 3 | auto lambda = [&](auto&& s) { F(s); }; | ~^~~ test.cc:11:17: note: declared private here 11 | static void g(int) {} | ^ ``` Clang accepts this code, making func's body just `{ F(0); }` compiles without errors as well.
[Bug c++/91465] [9/10 Regression] unexpected expression of kind overload (ICE)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91465 Maxime Coste changed: What|Removed |Added CC||mawww at kakoune dot org --- Comment #7 from Maxime Coste --- Any chance to get the proposed fix included in 9.3, what is currently missing ?
[Bug c++/94041] New: temporary object destructor called before the end of the full-expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94041 Bug ID: 94041 Summary: temporary object destructor called before the end of the full-expression Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mawww at kakoune dot org Target Milestone: --- Hello on current trunk, with no special options given, compiling the following code: struct Temp{ ~Temp(); }; struct A{ A(const Temp&) noexcept; }; struct B{ ~B(); }; struct Pair{ A a; B b; }; Temp make_temp() noexcept; void foo(const Pair&) noexcept; void bar(const Pair& p) noexcept { foo({A(make_temp()), p.b}); } generates the following assembly for the bar function: bar(Pair const&): pushrbp mov rbp, rsp sub rsp, 32 mov QWORD PTR [rbp-24], rdi lea rax, [rbp-1] mov rdi, rax callmake_temp() lea rdx, [rbp-1] lea rax, [rbp-3] mov rsi, rdx mov rdi, rax callA::A(Temp const&) lea rax, [rbp-1] mov rdi, rax callTemp::~Temp() [complete object destructor] lea rax, [rbp-3] mov rdi, rax callfoo(Pair const&) lea rax, [rbp-3] mov rdi, rax callPair::~Pair() [complete object destructor] nop leave ret Note the call to Temp::~Temp *before* the call to foo, which can lead to the A object referring to a dangling Temp object when accessed in foo. I believe that destructor call should only take place *after* calling foo, when the full-expression actually ends. This does not happen on gcc 9 and previous version, only on current trunk and gcc-10 as provided in fedora rawhide.
[Bug c++/89217] ICE tree check: expected constructor, have error_mark in split_nonconstant_init_1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89217 --- Comment #1 from Maxime Coste --- Forgot to mention that this is a regression since gcc 8.2.1 which compiles this code fine. It fails on gcc trunk r268563.
[Bug c++/89217] New: ICE tree check: expected constructor, have error_mark in split_nonconstant_init_1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89217 Bug ID: 89217 Summary: ICE tree check: expected constructor, have error_mark in split_nonconstant_init_1 Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mawww at kakoune dot org Target Milestone: --- Created attachment 45613 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45613=edit Source file that triggers the bug. Compiling the following source (attached as well): struct R {}; struct C { R* begin() const { return } R* end() const { return } R& r; }; struct S { void f1() { f2(); } template void f2() { for (auto i : C{r}) {} } R& r; }; Leads to an internal compiler error: test.cc: In instantiation of ‘void S::f2() [with bool = true]’: test.cc:13:26: required from here test.cc:18:9: error: cannot convert ‘((S*)this)->S::r’ from type ‘R’ to type ‘R*’ 18 | for (auto i : C{r}) {} | ^~~ test.cc:18:9: internal compiler error: tree check: expected constructor, have error_mark in split_nonconstant_init_1, at cp/typeck2.c:635 0x7bb804 tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../.././gcc/tree.c:9813 0x671510 tree_check(tree_node*, char const*, int, char const*, tree_code) ../.././gcc/tree.h:3176 0x671510 split_nonconstant_init_1 ../.././gcc/cp/typeck2.c:635 0xa5fced split_nonconstant_init(tree_node*, tree_node*) ../.././gcc/cp/typeck2.c:760 0x896f15 set_up_extended_ref_temp ../.././gcc/cp/call.c:11297 0x896f15 extend_ref_init_temps_1 ../.././gcc/cp/call.c:11434 0xa628a7 store_init_value(tree_node*, tree_node*, vec**, int) ../.././gcc/cp/typeck2.c:833 0x8f07c2 check_initializer ../.././gcc/cp/decl.c:6508 0x91079c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ../.././gcc/cp/decl.c:7184 0x9804b1 cp_convert_range_for(tree_node*, tree_node*, tree_node*, tree_node*, unsigned int, bool, unsigned short) ../.././gcc/cp/parser.c:12361 0x9cf457 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../.././gcc/cp/pt.c:17116 0x9cc449 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../.././gcc/cp/pt.c:17212 0x9cbdce tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../.././gcc/cp/pt.c:16896 0x9cbdce instantiate_decl(tree_node*, bool, bool) ../.././gcc/cp/pt.c:24584 0xa01f3b instantiate_pending_templates(int) ../.././gcc/cp/pt.c:24700 0x9200f0 c_parse_final_cleanups() ../.././gcc/cp/decl2.c:4792
[Bug tree-optimization/78528] New: Recursion not optimized in simple case
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78528 Bug ID: 78528 Summary: Recursion not optimized in simple case Product: gcc Version: 7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: mawww at kakoune dot org Target Milestone: --- The following code: struct Int { constexpr Int(int value) : m_value(value) {} constexpr friend Int operator+(Int lhs, Int rhs) { return {lhs.m_value + rhs.m_value}; } int m_value; }; Int strlen(const char* s) { return *s == 0 ? 0 : strlen(s+1) + 1; } when compiled with `-std=c++11 -O3` generates the following assembly for the strlen function: _Z6strlenPKc: .LFB4: .cfi_startproc cmpb$0, (%rdi) jne .L2 xorl%eax, %eax ret .p2align 4,,10 .p2align 3 .L2: cmpb$0, 1(%rdi) movl$1, %eax jne .L12 .L10: ret .p2align 4,,10 .p2align 3 .L12: cmpb$0, 2(%rdi) movl$2, %eax je .L10 subq$8, %rsp .cfi_def_cfa_offset 16 addq$3, %rdi call_Z6strlenPKc addq$8, %rsp .cfi_def_cfa_offset 8 addl$3, %eax ret .cfi_endproc As we can see, the generated code is still recursive, I think the optimizer should have optimized that, is it correctly does when we use 'int' instead of 'Int'.