Skip to content

probable initialization errors of heap allocated objects #153

Open
@chqrlie

Description

@chqrlie

I amended the library file libs/libc/stdlib.c2 this way:

// [...]
import string;
// [...]
#if 1
public fn void* malloc(c_size size) {
    void *p = calloc(size, 1);
    if (p) return string.memset(p, 0xff, size);
    return p;
}
#else
fn void* malloc(c_size size);
#endif

Running some tests with this library patch makes the compiler hang on macOS with an infinite loop.

output/tester/tester -v test/template/function/opaque_template_arg_ok.c2t

I suspect this is caused by a missing initializer for a field in an object allocated from the heap (directly or indirectly).

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