On Wed, 10 Feb 2021, Jakub Jelinek wrote: > On Wed, Feb 10, 2021 at 11:30:42AM +0100, Richard Biener wrote: > > The optimize pragma/attribute parsing calls decode_cmdline_options_to_array > > but doesn't free the array. The following fixes that. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? > > > > Thanks, > > Richard. > > > > 2021-02-10 Richard Biener <rguent...@suse.de> > > > > gcc/c-family/ > > * c-common.c (parse_optimize_options): Free decoded_options. > > --- > > gcc/c-family/c-common.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c > > index 813212cc21d..088626d1e09 100644 > > --- a/gcc/c-family/c-common.c > > +++ b/gcc/c-family/c-common.c > > @@ -5770,6 +5770,7 @@ parse_optimize_options (tree args, bool attr_p) > > decode_options (&global_options, &global_options_set, > > decoded_options, decoded_options_count, > > input_location, global_dc, NULL); > > + free (decoded_options); > > > > targetm.override_options_after_change(); > > If the option processing can't remember pointers into that array, sure. > But if something would do that, it would show up at least in valgrind or > asan-bootstrap.
option processing shouldn't remember pointers to a cl_decoded_option, it might remember entries but not by reference either and we just free the array here. I'm not sure asan-bootstrap would show anything since it requries optimize pragmas or attributes but the testsuite has quite some cases and that went clean. So pushed. Richard.