mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix build failure with GCC 13
It complains about *those* calls returning a dangling reference... Unfortunately, GCC does not provide more information about what the reference *is*. (It only mentions the temporary being destroyed at the end of this *huge* expression.) I am normally not one to just commit a thing that gets rid of a warning if I can't explain why, but this eludes me. Stubbing out the calls to only return a captured variable still complains, which led me to test that the error wasn't stemming from the `Visitor` itself... which it seems to? But I don't see why a reference to the *visitor* should be kept... Anyway, here is the obligatory part where I state my yearning for Rust :)
This commit is contained in:
@@ -62,7 +62,7 @@ std::string const &FileStackNode::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
||||||
std::string const &topName = std::visit(Visitor{
|
Visitor visitor{
|
||||||
[this](std::vector<uint32_t> const &iters) -> std::string const & {
|
[this](std::vector<uint32_t> const &iters) -> std::string const & {
|
||||||
assert(this->parent); // REPT nodes use their parent's name
|
assert(this->parent); // REPT nodes use their parent's name
|
||||||
std::string const &lastName = this->parent->dump(this->lineNo);
|
std::string const &lastName = this->parent->dump(this->lineNo);
|
||||||
@@ -80,7 +80,8 @@ std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
|||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
},
|
},
|
||||||
}, data);
|
};
|
||||||
|
std::string const &topName = std::visit(visitor, data);
|
||||||
fprintf(stderr, "(%" PRIu32 ")", curLineNo);
|
fprintf(stderr, "(%" PRIu32 ")", curLineNo);
|
||||||
return topName;
|
return topName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ std::string const &FileStackNode::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
||||||
std::string const &topName = std::visit(Visitor{
|
Visitor visitor{
|
||||||
[this](std::vector<uint32_t> const &iters) -> std::string const & {
|
[this](std::vector<uint32_t> const &iters) -> std::string const & {
|
||||||
assert(this->parent); // REPT nodes use their parent's name
|
assert(this->parent); // REPT nodes use their parent's name
|
||||||
std::string const &lastName = this->parent->dump(this->lineNo);
|
std::string const &lastName = this->parent->dump(this->lineNo);
|
||||||
@@ -87,7 +87,8 @@ std::string const &FileStackNode::dump(uint32_t curLineNo) const {
|
|||||||
[](std::monostate) -> std::string const & {
|
[](std::monostate) -> std::string const & {
|
||||||
unreachable_(); // This should not be possible
|
unreachable_(); // This should not be possible
|
||||||
},
|
},
|
||||||
}, data);
|
};
|
||||||
|
std::string const &topName = std::visit(visitor, data);
|
||||||
fprintf(stderr, "(%" PRIu32 ")", curLineNo);
|
fprintf(stderr, "(%" PRIu32 ")", curLineNo);
|
||||||
return topName;
|
return topName;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user