#224 closed defect (fixed)

Cannot initialize static local constant

Reported by: mlbrooks Owned by: Michael Brooks <mlbrooks@…>
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

Similar to #182, except here, the user's declaration is lexically scoped as local.

int main() {
    static const char bar = -1;
    printf("done\n");
}

Expected (everywhere): Compiles successfully and runs with output done

Actual (gcc8, gcc10): Compiles successfully and segfaults on startup.

Actual (gcc6): as expected

Change History (1)

comment:1 Changed 12 months ago by Michael Brooks <mlbrooks@…>

Owner: set to Michael Brooks <mlbrooks@…>
Resolution: fixed
Status: newclosed

In f1791a4:

Expanding earlier #182 fix to another case of the same issue. Fixes #224?

There is now a reusable helper function addDataSectonAttribute that applies the fix to an ObjectDecl? when we realize it needs it. Test const-init is expanded with case of #224.

Note: See TracTickets for help on using tickets.