Skip to content

init: run Initialize for static arrays of managed records (fixes upstream#41451) - #45

Open
Moonbot-Tech wants to merge 1 commit into
unleashedpascal:mainfrom
Moonbot-Tech:fix-41451
Open

init: run Initialize for static arrays of managed records (fixes upstream#41451)#45
Moonbot-Tech wants to merge 1 commit into
unleashedpascal:mainfrom
Moonbot-Tech:fix-41451

Conversation

@Moonbot-Tech

Copy link
Copy Markdown

Problem. FPC issue #41451: implicit finalization already covered managed static variables, but the paired initialization only accepted a top-level record or object, so a fixed array of advanced records received Finalize without Initialize.

Fix. Add one value-storage predicate, has_non_trivial_value_init, that recurses only through records, fixed arrays and old-style objects, and use it both for the initialization walk in ngenutil.pas and for the sto_has_non_trivial_init symtable flag. Class and interface references are excluded, so a large static string array is still initialized by a single zero fill.

Test. tests/webtbs/tw41451.pp: the array element's Initialize does not run on current main, runs after the fix.

Validation. Win64 build of main (a359fc1) with the patch; 405 neighbouring tests from tests/test (inline, rtti, helpers, generics, opt) give identical results before and after.

🤖 Generated with Claude Code

…ream#41451)

Implicit finalization already covered managed static variables, but the
paired initialization only accepted a top-level record or object, so a
fixed array of advanced records received Finalize without Initialize.

Add one value-storage predicate, has_non_trivial_value_init, that
recurses only through records, fixed arrays and old-style objects, and
use it both for the initialization walk and for the
sto_has_non_trivial_init symtable flag. Class and interface references
are excluded, so a large static string array is still initialized by a
single zero fill.

FPC issue: https://gitlab.com/freepascal.org/fpc/source/-/issues/41451

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@fibodevy fibodevy added the waiting-upstream Stock FPC fix, waits for the upstream MR to be merged or rejected label Sep 6, 2026
@Moonbot-Tech

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-upstream Stock FPC fix, waits for the upstream MR to be merged or rejected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants