diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2024-07-19 12:44:32 -0400 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2024-07-20 12:22:10 -0400 |
commit | a23deb15053134840ba77d19d96b0f0771f696bf (patch) | |
tree | 5b4b0a4f59ac494377c30498bf3ef22f6617b414 | |
parent | 130edabae09e18064e0bdcb12656e4f4f9a51ff3 (diff) | |
download | gcc-a23deb15053134840ba77d19d96b0f0771f696bf.zip gcc-a23deb15053134840ba77d19d96b0f0771f696bf.tar.gz gcc-a23deb15053134840ba77d19d96b0f0771f696bf.tar.bz2 |
Avoid undefined behaviour in build_option_suggestions
The inner loop in build_option_suggestions uses OPTION to take the
address of OPTB and use it across iterations, which is undefined
behaviour since OPTB is defined within the loop. Pull it outside the
loop to make this defined.
gcc/ChangeLog:
* opt-suggestions.cc
(option_proposer::build_option_suggestions): Pull OPTB
definition out of the innermost loop.
(cherry picked from commit e0d997e913f811ecf4b3e10891e6a4aab5b38a31)
-rw-r--r-- | gcc/opt-suggestions.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/opt-suggestions.cc b/gcc/opt-suggestions.cc index cc0adc2..1f40db3 100644 --- a/gcc/opt-suggestions.cc +++ b/gcc/opt-suggestions.cc @@ -167,9 +167,9 @@ option_proposer::build_option_suggestions (const char *prefix) add_misspelling_candidates (m_option_suggestions, option, opt_text); + struct cl_option optb; for (int j = 0; sanitizer_opts[j].name != NULL; ++j) { - struct cl_option optb; /* -fsanitize=all is not valid, only -fno-sanitize=all. So don't register the positive misspelling candidates for it. */ |