erase() invalidates the iterator and returns a new one pointing
to the following element. The code now follows the example at
https://en.cppreference.com/w/cpp/container/map/erase.
(The added testcase crashes without this patch.)
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Not related to this patch, but I think there is one more potentially incorrect use of containers in RTLsTy::RegisterLib(). This function may increase size of the global vector Devices when it initializes a new RTL that has not been yet used (see rtl.cpp line 219). This may result in memory reallocation and thus all pointers to the Devices elements that are stored in RTLs (see rtl.cpp line 228) would become invalid. I am not sure if these pointers are really used by RTLs now, but if yes, than it is a problem. RTLsTy::RegisterLib may be called more than once and each call may potentially initialize new RTLs.
Hehe, turns out: Yes and no!
Yes, this is undoubtly incorrect. But no, this can never happen because nobody is accessing the RTLInfoTy::Devices :D
Do you want to submit a patch removing Devices from RTLInfoTy?