mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 08:46:53 +08:00
Using GCC 13.3.0 I get warnings like the following:
```
In file included from .../ChaiScript/static_libs/../include/chaiscript/language/chaiscript_optimizer.hpp:10,
from .../ChaiScript/static_libs/../include/chaiscript/language/chaiscript_parser.hpp:26,
from .../ChaiScript/static_libs/chaiscript_parser.cpp:1:
.../ChaiScript/static_libs/../include/chaiscript/language/chaiscript_eval.hpp: In instantiation of ‘chaiscript::Boxed_Value chaiscript::eval::Global_Decl_AST_Node<T>::eval_internal(const chaiscript::detail::Dispatch_State&) const [with T = chaiscript::eval::Tracer<chaiscript::eval::Noop_Tracer_Detail>]’:
.../ChaiScript/static_libs/../include/chaiscript/language/chaiscript_eval.hpp:503:19: required from here
.../ChaiScript/static_libs/../include/chaiscript/language/chaiscript_eval.hpp:504:28: warning: possibly dangling reference to a temporary [-Wdangling-reference]
504 | const std::string &idname = [&]() -> const std::string & {
| ^~~~~~
.../ChaiScript/static_libs/../include/chaiscript/language/chaiscript_eval.hpp:510:10: note: the temporary was destroyed at the end of the full expression ‘<lambda closure object>chaiscript::eval::Global_Decl_AST_Node<chaiscript::eval::Tracer<chaiscript::eval::Noop_Tracer_Detail> >::eval_internal(const chaiscript::detail::Dispatch_State&) const::<lambda()>{((const chaiscript::eval::Global_Decl_AST_Node<chaiscript::eval::Tracer<chaiscript::eval::Noop_Tracer_Detail> >*)this)}.chaiscript::eval::Global_Decl_AST_Node<chaiscript::eval::Tracer<chaiscript::eval::Noop_Tracer_Detail> >::eval_internal(const chaiscript::detail::Dispatch_State&) const::<lambda()>()’
504 | const std::string &idname = [&]() -> const std::string & {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
505 | if (this->children[0]->identifier == AST_Node_Type::Reference) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
506 | return this->children[0]->children[0]->text;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
507 | } else {
| ~~~~~~~~
508 | return this->children[0]->text;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
509 | }
| ~
510 | }();
| ~^~
```
Fix this by replacing the lambda with a simple ternary operator
expression.
|
||
|---|---|---|
| .. | ||
| chaiscript_algebraic.hpp | ||
| chaiscript_common.hpp | ||
| chaiscript_engine.hpp | ||
| chaiscript_eval.hpp | ||
| chaiscript_optimizer.hpp | ||
| chaiscript_parser.hpp | ||
| chaiscript_posix.hpp | ||
| chaiscript_prelude_docs.hpp | ||
| chaiscript_prelude.hpp | ||
| chaiscript_tracer.hpp | ||
| chaiscript_unknown.hpp | ||
| chaiscript_windows.hpp | ||