From f4a55415fc711a4a088b93ed0b0cbcb3aa6504f1 Mon Sep 17 00:00:00 2001 From: Martin Suda Date: Fri, 9 Oct 2026 14:39:41 +0200 Subject: [PATCH] Include the BottomUpChildIter specialization in Polynomial.hpp PolyNf::SubtermIter holds a Stack>, but Polynomial.hpp only included the primary template (BottomUpEvaluation.hpp). A TU that destroys a SubtermIter without including PolynomialBottomUpEvaluation.hpp itself (e.g. ALASCA/VariableElimination.cpp) instantiated ~Stack with the empty primary template: an ODR violation that frees the stack buffer with a wrong (too small) size. Reproducer: GCC LTO build warns Kernel/PolynomialBottomUpEvaluation.hpp:26:8: warning: type 'struct BottomUpChildIter' violates the C++ One Definition Rule [-Wodr] and `c++ -std=c++17 -I. -E Inferences/ALASCA/VariableElimination.cpp | grep -c PolynomialBottomUpChildIter` printed 0 before this commit. Co-Authored-By: Claude Opus 5.5 --- Kernel/Polynomial.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Kernel/Polynomial.hpp b/Kernel/Polynomial.hpp index e4c02f7a5..bd19c4b79 100644 --- a/Kernel/Polynomial.hpp +++ b/Kernel/Polynomial.hpp @@ -661,8 +661,9 @@ IterTraits iterArgsPnf(Literal* lit); } // namespace Kernel -// include needs to go here, since we need the specialization BottomUpChildIter to declare Iter -#include "Kernel/BottomUpEvaluation.hpp" +// include needs to go here: the specialization BottomUpChildIter needs PolyNf complete, and +// every TU that uses PolyNf::SubtermIter must see it (otherwise the empty primary template gets instantiated, an ODR violation) +#include "Kernel/PolynomialBottomUpEvaluation.hpp" namespace Kernel {