Fedora Account System
Red Hat Associate
Red Hat Customer
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
// 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'; }
Reproducer on Compiler Explorer: https://godbolt.org/z/Ez7xnbddf
Filed upstream as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123880
Should be fixed upstream on trunk by r16-7206-gb5d5cab8e4b807.
So should be then fixed in gcc-16.0.1-0.6.fc4* and later.