Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

reference to declaration through sizeof in initializer causes undeclared identifier #223

@MrBrN197

Description

@MrBrN197

Zig Version

0.16.0-dev.1204+389368392

Steps to Reproduce and Observed Behavior

typedef struct {} Object;

Object* alloc(int t) {
  return 0;
}

int main() {
   Object *ptr = alloc(sizeof(*ptr));
 }

zig translate-c src/test.c | zig ast-check

<stdin>:11:80: error: use of undeclared identifier 'ptr'
    var ptr: [*c]Object = alloc(@bitCast(@as(c_uint, @truncate(@sizeOf(@TypeOf(ptr.*))))));                                                                               ^~~

Expected Behavior

compile without errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions