From 9267b57c5404fb491d707dca026d0b18855dc2db Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 30 Oct 2015 05:41:36 +0100 Subject: [PATCH] fix endless recursion on copy initialisation from Ref The Ref-GenNode is just a specifically constructed GenNode, and intended to be sliced down to an ordinary GenNode immediately after construction. It seems, GCC didn't "get that" and instead emitted an recursive invocation of the same ctor, which obviously leads to stack overflow. Problem solved by explicitly coding the copy initialisation, after the full definition of Ref is available. --- src/lib/diff/gen-node.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index d4edb64be..44dbbf7cb 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -254,10 +254,10 @@ namespace diff{ ////////////////////////TICKET #963 Forwarding shadows copy operations -- generic solution?? GenNode(GenNode const&) =default; GenNode(GenNode&&) =default; - GenNode(GenNode& o) : GenNode((GenNode const&)o) { } - GenNode(Ref const& r) : GenNode((GenNode const&)r) { } - GenNode(Ref & r) : GenNode((GenNode const&)r) { } - GenNode(Ref && r) : GenNode((GenNode &&)r) { } + GenNode(GenNode& o) : GenNode((GenNode const&)o) { } + GenNode(Ref const& r); + GenNode(Ref & r); + GenNode(Ref && r); GenNode& operator= (GenNode const&) =default; GenNode& operator= (GenNode&&) =default; @@ -601,6 +601,12 @@ namespace diff{ }; + // slice down on copy construction... + inline GenNode::GenNode(Ref const& r) : idi(r.idi), data(r.data) { } + inline GenNode::GenNode(Ref & r) : idi(r.idi), data(r.data) { } + inline GenNode::GenNode(Ref && r) : idi(std::move(r.idi)), + data(std::move(r.data)) { } + /* === Specialisation to add fluent GenNode builder API to Record === */