Bug 2435317

Summary: error interno del compilador: en on_throw, en analyzer/engine.cc:1814
Product: [Fedora] Fedora Reporter: gustavo <gustavo>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 44CC: dmalcolm, fweimer, jakub, jlaw, josmyers, jwakely, mcermak, mpolacek, msebor, nickc, nixuser, sipoyare
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
URL: https://pccito.ugr.es/bug/
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-03-04 11:55:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description gustavo 2026-01-29 16:22:27 UTC
gustavo@casa:~/src/c++/bug$ LANG=C make
g++ -fanalyzer -g -march=native -O3 -std=c++23    tree.cc   -o tree
during IPA pass: analyzer
In file included from tree.cc:1:
/usr/include/c++/16/generator: In member function 'void std::__gen::_Promise_erased<_Yielded>::unhandled_exception() [with _Yielded = const char&]':
/usr/include/c++/16/generator:198:13: internal compiler error: in on_throw, at analyzer/engine.cc:1814
  198 |             throw;
      |             ^~~~~
Please submit a full bug report, with preprocessed source.
See <https://bugzilla.redhat.com/> for instructions.
rm cc	Preprocessed source stored into /tmp/ccsgapIK.out file, please attach this to your bugreport.
make: *** [<builtin>: tree] Error 1

Reproducible: Always

Steps to Reproduce:
1. try to compile the source code with -fanalyzer activated on gcc
2.
3.
Actual Results:
interna compiler error


Additional Information:
gcc versión 16.0.1 20260115 (Red Hat 16.0.1-0) (GCC) from rawhide

Comment 1 gustavo 2026-01-29 16:25:24 UTC
// this is the source code...

#include <generator>
#include <iostream>

template<typename T> struct Tree
{
    T value;
    Tree *left{}, *right{};

    std::generator<const T &> traverse_preorder() const
    {
        co_yield value;
        if (left)
            co_yield std::ranges::elements_of(left->traverse_preorder());
        if (right)
            co_yield std::ranges::elements_of(right->traverse_preorder());
    }
};

int main()
{
    Tree<char> tree[]
    {
                                    {'D', tree + 1, tree + 2},
        //                            │
        //            ┌───────────────┴────────────────┐
        //            │                                │
                    {'B', tree + 3, tree + 4},       {'F', tree + 5, tree + 6},
        //            │                                │
        //  ┌─────────┴─────────────┐      ┌───────────┴─────────────┐
        //  │                       │      │                         │
          {'A'},                  {'C'}, {'E'},                    {'G'}
    };

    std::cout << " Preorder: ";
    for (char x : tree->traverse_preorder())
        std::cout << x << ' ';
    std::cout << '\n';
}

Comment 2 Dave Malcolm 2026-01-29 17:53:27 UTC
Reproducer on Compiler Explorer: https://godbolt.org/z/Ez7xnbddf

Comment 3 Dave Malcolm 2026-01-29 18:40:44 UTC
Filed upstream as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123880

Comment 4 Dave Malcolm 2026-01-31 04:39:41 UTC
Should be fixed upstream on trunk by r16-7206-gb5d5cab8e4b807.

Comment 5 Jakub Jelinek 2026-03-04 11:55:49 UTC
So should be then fixed in gcc-16.0.1-0.6.fc4* and later.