Skip to content

Global primitive definition macro uses incorrect designator order #357

@abelstuker

Description

@abelstuker

The different def_glob macros for primitive global variables each use an incorrect designator order, not matching the declaration order in Global. This is the case for all platforms supporting primitive global installation.

#define def_glob(name, type, mut, init_value)             \
    StackValue name##_sv{.value_type = type, init_value}; \
    Global name = {                                       \
        .mutability = mut, .import_field = #name, .value = &name##_sv};

While the global struct is defined as:

typedef struct Global {
    char *export_name;    // export name of the global
    char *import_module;  // import module name
    char *import_field;   // import field name
    bool mutability;      // 0: immutable, 1: mutable
    StackValue *value;    // current value
} Global;

This results in a compiler error and breaks CI when the def_glob macro is used:

error: designator order for field ‘Global::import_field’ does not match declaration order in ‘Global’

The error was not catched in #329 since that PR didn't include any effective use of those primitive global variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions