From 1f1200e5e8f765ccd0e8a842d0eeab02077b8539 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Fri, 11 Oct 2024 08:16:59 -0700 Subject: [PATCH] fixed "-O gen-C++" naming of "when" captures to avoid ambiguities due to inlining Previously there was logic for doing this, but it was ineffectual due to the order in which canonicalization was done. This problem manifested non-deterministically depending on order-of-generation of "when" lambdas, which is why previous testing didn't catch it. --- src/script_opt/CPP/Vars.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/script_opt/CPP/Vars.cc b/src/script_opt/CPP/Vars.cc index 4413395304..bdbf62e8ac 100644 --- a/src/script_opt/CPP/Vars.cc +++ b/src/script_opt/CPP/Vars.cc @@ -133,15 +133,13 @@ string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name( string CPPCompile::CaptureName(const ID* c) const { // We want to strip both the module and any inlining appendage. - auto n = Canonicalize(trim_name(c).c_str()); + auto tn = trim_name(c); - auto appendage = n.find("."); - if ( appendage != string::npos ) { - n.erase(n.begin() + appendage, n.end()); - n.push_back('_'); - } + auto appendage = tn.find("."); + if ( appendage != string::npos ) + tn.erase(tn.begin() + appendage, tn.end()); - return n; + return Canonicalize(tn.c_str()); } string CPPCompile::Canonicalize(const char* name) const {