yosys/passes/proc
Charlotte 63e4114233 proc_prune: avoid using invalidated iterator
An `std::vector<T>::reverse_iterator` stores the
`std::vector<T>::iterator` which points to the (forwards-ordered)
*following* item.  Thus while `vec.rbegin()` dereferences to the final
item of `vec`, the iterator it wraps (`vec.rbegin().base()`) is equal to
`vec.end()`.

In the remove case here, we advance `it` (backwards), erasing the item
we just advanced past by grabbing its (pre-increment) base
forward-iterator and subtracting 1.

The iterator maths here is obviously all OK, but the forward-iterator
that `it` wraps post-increment actually points to the item we just
removed.  That iterator was invalidated by the `erase()` call.

That this works anyway is (AFAICT) some combination of luck and/or
promises that aren't part of the C++ spec, but MSVC's debug iterator
support picks this up.

`erase()` returns the new iterator that follows the item just erased,
which happens to be the exact one we want our reverse-iterator to wrap
for the next loop; we get a fresh iterator to the same base, now without
the preceding item.
2023-06-21 19:53:08 +10:00
..
Makefile.inc Add proc_rom pass. 2022-05-13 00:37:14 +02:00
proc.cc Add proc_rom pass. 2022-05-13 00:37:14 +02:00
proc_arst.cc Fixing old e-mail addresses and deadnames 2021-06-08 00:39:36 +02:00
proc_clean.cc rtlil: Make Process handling more uniform with Cell and Wire. 2021-07-12 00:47:34 +02:00
proc_dff.cc Fixes for some of clang scan-build detected issues 2023-01-17 12:58:08 +01:00
proc_dlatch.cc Fixing old e-mail addresses and deadnames 2021-06-08 00:39:36 +02:00
proc_init.cc Delete unused found_init variable 2021-07-14 10:19:07 +01:00
proc_memwr.cc proc_memwr: Use the v2 memwr cell. 2021-08-11 13:34:10 +02:00
proc_mux.cc Fixing old e-mail addresses and deadnames 2021-06-08 00:39:36 +02:00
proc_prune.cc proc_prune: avoid using invalidated iterator 2023-06-21 19:53:08 +10:00
proc_rmdead.cc proc_rmdead: use explicit pattern set when there are no wildcards 2021-07-29 20:55:59 -04:00
proc_rom.cc proc_rom: Add special handling of const-0 address bits. 2022-05-18 17:32:30 +02:00