https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106824
--- Comment #2 from David Binderman <dcb314 at hotmail dot com> --- After more than 13 hours of reduction, the C++ code seems to be: using int32 = int; using int64 = long; float NoWeight___trans_tmp_2; int ShortestPath_distance; struct FloatWeightTpl { FloatWeightTpl(float f) : value_(f) {} float Value() { return value_; } float value_; }; template <class T> bool operator!=(FloatWeightTpl w1, T w2) { bool __trans_tmp_4; FloatWeightTpl __trans_tmp_5 = w1; __trans_tmp_4 = __trans_tmp_5.Value() == w2.Value(); return !__trans_tmp_4; } template <class> struct TropicalWeightTpl : FloatWeightTpl { TropicalWeightTpl(float f) : FloatWeightTpl(f) {} static TropicalWeightTpl Zero(); static TropicalWeightTpl NoWeight() { NoWeight___trans_tmp_2 = __builtin_nanf(""); return NoWeight___trans_tmp_2; } bool Member() { return value_; } }; template <class T> constexpr TropicalWeightTpl<T> Plus(TropicalWeightTpl<T> w2) { return w2.Member() ? TropicalWeightTpl<T>::NoWeight() : w2; } float Times(); struct ArcTpl { using Weight = TropicalWeightTpl<float>; }; template <class, class, class> struct ShortestPathOptions { using Weight = ArcTpl::Weight; ShortestPathOptions(int, int, int32, bool, bool, float, bool, Weight); }; template <class Arc, class Queue, class ArcFilter> void SingleShortestPath(ShortestPathOptions<Arc, Queue, ArcFilter>) { using Weight = typename Arc::Weight; auto f_distance = Weight::Zero(); TropicalWeightTpl<float> __trans_tmp_1 = Times(), plus = Plus(__trans_tmp_1); if (f_distance != plus) f_distance = plus; if (f_distance.Member()) for (;;) ; } template <class Arc, class Queue, class ArcFilter> void ShortestPath(int, int *, int *, ShortestPathOptions<Arc, Queue, ArcFilter> opts) { SingleShortestPath(opts); } struct ShortestDistanceOptions { float delta; }; struct Trans_NS_script_ShortestPathOptions : ShortestDistanceOptions { int32 nshortest; bool unique; int64 state_threshold; }; namespace internal { template <class, class> void ShortestPath(int ifst, int *ofst, int *distance, Trans_NS_script_ShortestPathOptions opts) { using ArcFilter = int; ShortestPathOptions<ArcTpl, int, ArcFilter> sopts( 0, ArcFilter(), opts.nshortest, opts.unique, false, opts.delta, 0, opts.state_threshold); ShortestPath(ifst, ofst, distance, sopts); } int ShortestPath_ifst; int ShortestPath_ofst; Trans_NS_script_ShortestPathOptions ShortestPath_opts; void ShortestPath() { using StateId = int; ShortestPath<ArcTpl, StateId>(ShortestPath_ifst, &ShortestPath_ofst, &ShortestPath_distance, ShortestPath_opts); } } // namespace internal I will have a go at a bisect on git.