[Chapel Merge] Fix (C++) errors introduced by the "better (Chapel

Branch: refs/heads/main
Revision: 6a3f1b3
Author: DanilaFe
Link: Fix (C++) errors introduced by the "better (Chapel) error messages" PR by DanilaFe · Pull Request #20770 · chapel-lang/chapel · GitHub
Log Message:

Merge pull request #20770 from DanilaFe/fix-better-errors

Fix (C++) errors introduced by the "better (Chapel) error messages" PR

Attempts to compile with -Wall -Werror brought out issues that hadn't been
caught by my local testing or GitHub CI. In particular, loc.path() goes out of
scope right after the line on which its c_str() is retrieved, creating a dangling
pointer issue. To fix this, it's necessary to keep the path() in scope until the
last use of the c-string.

This PR also updates chpldoc futures to also have the new error message format.

Reviewed by @mppf and @dlongnecke-cray - thanks!

Testing: