I believe the cause is shared parameter metadata: an inferred function-pointer type shares the original function’s parameter symbols. Processing the new declaration renames those shared symbols. Copying the parameter list for the inferred type prevents that.
I'll attach a patch as soon as I can.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The missing symbol is _next_value_10000_9. The original parameter's storage metadata has been changed while processing the inferred pointer declaration, leaving its generated code referring to unallocated storage. The inferred type and original function share FUNC_ARGS: copyLinkChain copies the function link, but not its parameter values or symbols.
The candidate fix for this regression copies each function declarator's parameter chain in the inferred type. It leaves the original function's symbols intact. There is no need to weaken the existing regression test or make its function reentrant merely to avoid the failure.
All new test cases are in regression. They are valid programs; the required observations are successful linking and correct call results. There are no diagnostic expectations that would justify a valdiag file.
bug-4139.c: reproduces all three reported link failures. After the fix, all 18 assertions pass on each reported target.
bug-4141.c: function conversion, explicit address, copying an inferred pointer, another source function, and direct calls after inference. These tests exercise independent parameter metadata and actual argument passing. A reentrant two-argument function checks parameter order and
values where indirect calls require reentrancy. The call count checks that all expected calls happened. Before the fix this test fails to link on all three reported targets; after it all 12 assertions pass on each.
The new test uses a counter in its callees so HC08 cannot keep every parameter entirely in registers and thereby hide the storage defect.
101 files in valdiag have unchanged results on each of HC08, MCS51 large/stack-auto, STM8 and Z80.
But I also noticed that the regression tests bug-4139.c, bug-4140.c & bug-4141.c all fail for host with GCC v11.4. Is there a macro that can be checked for these tests?
I'm sorry about the regression.
I believe the cause is shared parameter metadata: an inferred function-pointer type shares the original function’s parameter symbols. Processing the new declaration renames those shared symbols. Copying the parameter list for the inferred type prevents that.
I'll attach a patch as soon as I can.
The missing symbol is
_next_value_10000_9. The original parameter's storage metadata has been changed while processing the inferred pointer declaration, leaving its generated code referring to unallocated storage. The inferred type and original function shareFUNC_ARGS:copyLinkChaincopies the function link, but not its parameter values or symbols.The candidate fix for this regression copies each function declarator's parameter chain in the inferred type. It leaves the original function's symbols intact. There is no need to weaken the existing regression test or make its function reentrant merely to avoid the failure.
All new test cases are in
regression. They are valid programs; the required observations are successful linking and correct call results. There are no diagnostic expectations that would justify avaldiagfile.bug-4139.c: reproduces all three reported link failures. After the fix, all 18 assertions pass on each reported target.
bug-4141.c: function conversion, explicit address, copying an inferred pointer, another source function, and direct calls after inference. These tests exercise independent parameter metadata and actual argument passing. A reentrant two-argument function checks parameter order and
values where indirect calls require reentrancy. The call count checks that all expected calls happened. Before the fix this test fails to link on all three reported targets; after it all 12 assertions pass on each.
The new test uses a counter in its callees so HC08 cannot keep every parameter entirely in registers and thereby hide the storage defect.
101 files in
valdiaghave unchanged results on each of HC08, MCS51 large/stack-auto, STM8 and Z80.Please consider the attached candidate bug fix.
I intend to apply this patch.
But I also noticed that the regression tests bug-4139.c, bug-4140.c & bug-4141.c all fail for host with GCC v11.4. Is there a macro that can be checked for these tests?