One more obvious fix that unblocks ASAN bootstrap.
Martin
gcc/ChangeLog:
* toplev.c (toplev::main): Check opt_index if it is a part
of cl_options.
---
gcc/toplev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/toplev.c b/gcc/toplev.c
index d952319ad95..ec9f998a49b 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2339,7 +2339,8 @@ toplev::main (int argc, char **argv)
/* Save Optimization decoded options. */
for (unsigned i = 1; i < save_decoded_options_count; ++i)
- if (cl_options[save_decoded_options[i].opt_index].flags & CL_OPTIMIZATION)
+ if (save_decoded_options[i].opt_index < cl_options_count
+ && cl_options[save_decoded_options[i].opt_index].flags &
CL_OPTIMIZATION)
save_opt_decoded_options.safe_push (save_decoded_options[i]);
/* Perform language-specific options initialization. */
--
2.33.0