Skip to content

C++ global object initialization order reversed #6870

Closed
@earlephilhower

Description

@earlephilhower

@mikee47 and @slaff noted in the Sming repo that the core is calling the c++ ctors in reverse order:
SmingHub/Sming#1825 (comment)

static void do_global_ctors(void) {
static struct object ob;
__register_frame_info( __eh_frame, &ob );
void (**p)(void) = &__init_array_end;
while (p != &__init_array_start)
(*--p)();
}

I believe w/in a single file/TU, they should be called in the order in which they appear. So calling them backwards may break something if there are inter-object dependencies in global objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions