Open nvssynthesis opened 3 weeks ago
Good catch!
I do like your solution, but I'd prefer to keep the example code as focused as possible. With that in mind, I think it's best to keep the getModelFile()
method minimal, even if it's not "bulletproof".
That said, potentially de-referencing path.end()
isn't great, especially since implementations of the STL might flag it with a run-time assertion.
How's this as a minimal but better solution:
// get path of RTNeural root directory
while(path.filename() != "RTNeural")
path = path.parent_path();
Yeah, makes sense to keep it simple. That works!
In the "getModelFile" function, within the loop
while((--path.end())->string() != "RTNeural") path = path.parent_path();
, you are dereferencing an iterator with(--path.end())->string()
. According to cppreference, "Dereferencing [the end] iterator is undefined behavior". I believe this led to a bug at runtime using Clang.The implementation of getModelFile I ended up replacing it with (for now) looks like: