[Bug c++/109686] New: Errorneous infinite loop detection (-Winfinite-recursion)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109686 Bug ID: 109686 Summary: Errorneous infinite loop detection (-Winfinite-recursion) Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: madhur4127 at gmail dot com Target Milestone: --- This code: ``` #define myassert(x) \ do { \ if (! (x) ) \ abort(); \ } while (false) static void recursive(int n) { myassert(n > 0); recursive(n - 1); printf("%d\n", n); } ``` should not result in infinite recursion. Assert fails for all non-positive integers. For positive numbers it counts down to 0 and then fails. This affect GCC12, GCC13 and trunk: https://compiler-explorer.com/z/57qrnzdEK
[Bug middle-end/107334] Incorrect "infinite recursion detected" warning if base case aborts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107334 Madhur Chauhan changed: What|Removed |Added CC||madhur4127 at gmail dot com --- Comment #2 from Madhur Chauhan --- *** Bug 109686 has been marked as a duplicate of this bug. ***
[Bug middle-end/109686] Errorneous infinite loop detection (-Winfinite-recursion)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109686 Madhur Chauhan changed: What|Removed |Added Resolution|--- |DUPLICATE Status|UNCONFIRMED |RESOLVED --- Comment #2 from Madhur Chauhan --- Yes it's a dupe. Sorry. *** This bug has been marked as a duplicate of bug 107334 ***
[Bug middle-end/107334] Incorrect "infinite recursion detected" warning if base case aborts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107334 --- Comment #3 from Madhur Chauhan --- I feel changing the warning text will still cause troubles for people using -Werror. This forces to use ignore pragmas or disable this warning completely, none of them are ideal. Maybe disable warning in this case?
[Bug c++/110383] New: Missed optimiztion: Default operator== with trivial struct can be replaced with bcmp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110383 Bug ID: 110383 Summary: Missed optimiztion: Default operator== with trivial struct can be replaced with bcmp Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: madhur4127 at gmail dot com Target Milestone: --- Godbolt: https://compiler-explorer.com/z/Gr8E5zfo5 Default operator== produces inefficient assembly where it checks for each data member therefore having a lot of branches. Clang produces better assembly with memcmp / bcmp. I know its hard to generalize performance claims but in the worst case having 8 branches (one for each member), is not more efficient than a bcmp.
[Bug target/116414] New: Missed optimization: Branch elimination and memory writes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116414 Bug ID: 116414 Summary: Missed optimization: Branch elimination and memory writes Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: madhur4127 at gmail dot com Target Milestone: --- Godbolt: https://godbolt.org/z/oKrGfh34z Code: ``` #include #include std::optional x(uint16_t x) { return x <= 1 ? std::nullopt : std::optional{x}; } ``` GCC trunk generates a branch and uses memory writes whereas it could just use `eax` like clang ``` x(unsigned short): cmp di, 1 jbe .L5 mov WORD PTR [rsp-4], di mov BYTE PTR [rsp-2], 1 mov eax, DWORD PTR [rsp-4] ret .L5: mov BYTE PTR [rsp-2], 0 mov eax, DWORD PTR [rsp-4] ret ``` clang: ``` x(unsigned short): xor eax, eax cmp di, 2 setae al shl eax, 16 or eax, edi ret ```