https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111014
Bug ID: 111014 Summary: do_spec_1 terminates arguments too eagerly when processing spec function Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: p...@gcc-bugzilla.mail.kapsi.fi Target Milestone: --- Hi. do_spec_1 always terminates the current argument (via end_going_arg) if processing a spec function. 6881 if (processing_spec_function) 6882 end_going_arg (); If a spec function returns a non-null string it is expanded using do_spec_1. 7043 funcval = eval_spec_function (func, args, soft_matched_part); 7044 if (funcval != NULL && do_spec_1 (funcval, 0, NULL) < 0) However, because processing_spec_function is in this case non-zero, there is always a termination after each nested %-sequence has been processed. Thus, e.g. "%:version-compare(>= 1.0 -version-compare= %%(do_spec))" and "%(do_spec)" behave differently if the expanded %-sequences have any trailing parts: # cat version_compare_string.spec *self_spec: + --version-compare=1.0 %<-version-compare=* *do_spec: -W%{!Werror:no-}error *cc1_options: + %:version-compare(>= 1.0 -version-compare= %%(do_spec)) %(do_spec) # gcc -c -xc -specs=version_compare_string.spec - < /dev/null cc1: error: unrecognized command-line option ‘-Wno-’ [...] In the first case, do_spec is not expanded as "-Wno-error" but as "-Wno-" and "error". I wonder if this termination is really necessary; the same effect can be archieved by simply having a whitespace character to follow the spec function, if concatenation is not to be desired.