Source code is if (m_vars[i].type.dst == c_extended_type && i < vars_total) { it might be wise to sanity check i before use, not after.
Confirmed. But the code is probably unmaintained - HJ, whose the Intel contact to work on MIC (or is it time to rip out intelmic support given Knights-* is dead?)
The code is like: for (int i = 0; i < m_vars_total; i++) { // instead of m_vars[i].type.src we will use m_vars_extra[i].type_src if (i < vars_total) { ...... if (m_vars[i].type.dst == c_extended_type && i < vars_total) ...... } ...... } So the later ***i < vars_total*** is not actually needed.
svn blame says Ilya Verbin wrote this code; cc-ing
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:98f7381d17a1ad47773b70a5de7d94a164357916 commit r11-75-g98f7381d17a1ad47773b70a5de7d94a164357916 Author: Martin Liska <mliska@suse.cz> Date: Tue Feb 4 14:57:59 2020 +0100 Put index check before use. liboffloadmic/ChangeLog: 2020-02-04 Martin Liska <mliska@suse.cz> PR other/89860 * runtime/offload_target.cpp: Put index check before its use.
Fixed on master.