Skip to content

[Bug] Some function-like macros evaluate their arguments multiple times #43

Description

@brightprogrammer

Several function-like macros expand a runtime argument into two or more evaluating
positions, so an argument with side effects is evaluated more than once
(e.g. IntToStr(*p++)).

Examples:

  • IntToStr_1(value) -> int_to_str((value), IntAllocator((value)))value twice.
  • StrInitFromZstr_1(zstr) -> ... ((zstr), ZstrLen(zstr))zstr twice.
  • Str{PushBack,PushFront,Insert}Many _Generic forms — source used as the pointer
    and again inside ZstrLen(...).

Fix direction: route the reused derivation through single-eval functions
(cross-compiler, no statement-expressions), keeping behaviour and tests unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions