mirror of
https://github.com/YosysHQ/yosys
synced 2026-02-14 12:51:48 +00:00
Work around std::reverse miscompilation with empty range
This causes problems when compiling with fuzzing instrumenation enabled.
This commit is contained in:
parent
3b563b877e
commit
9e523e2fd7
1 changed files with 4 additions and 2 deletions
|
|
@ -286,6 +286,7 @@ struct RTLILFrontendWorker {
|
|||
if (width > MAX_CONST_WIDTH)
|
||||
error("Constant width %lld out of range before `%s`.", width, error_token());
|
||||
bits.reserve(width);
|
||||
int start_idx = idx;
|
||||
while (true) {
|
||||
RTLIL::State bit;
|
||||
switch (line[idx]) {
|
||||
|
|
@ -300,8 +301,9 @@ struct RTLILFrontendWorker {
|
|||
bits.push_back(bit);
|
||||
++idx;
|
||||
}
|
||||
done:
|
||||
std::reverse(bits.begin(), bits.end());
|
||||
done:
|
||||
if (start_idx < idx)
|
||||
std::reverse(bits.begin(), bits.end());
|
||||
|
||||
if (GetSize(bits) > width)
|
||||
bits.resize(width);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue