Antonio Caggiano - 4 hours ago

I have prepared a proposed fix against #16889, with regression tests.

In defaultOClass, the S_CODE path installs a synthetic zero initializer before the translation unit has been fully parsed. This makes the tentative definition appear initialized, so addSymChain later rejects the actual initialized definition as a duplicate.

Removing that synthetic initializer alone is not sufficient. After functions ,flushStatics() is called, which can emit the object before its later definition is encountered. The patch defers tentative objects during these early flushes and uses zero initialization at the end of processing a translation unit, during final emission. It also preserves custom constant-section placement.

Validation on SM83 using ucgbz80: the full regression suite passed with 0 failures, 36,602 tests, and 6,409 test cases, using the snapshot runtime. The tentdecl diagnostic suite passed all 19 cases.

The patch also includes a separate regression for an uninitialized nested constant aggregate, previously rejected with “initialization needs curly braces.”, possibly related to https://sourceforge.net/p/sdcc/bugs/3121/

I have not tested other targets.