Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: no init symbol for zero-initialized struct #4751

Open
Zoadian opened this issue Sep 10, 2024 · 1 comment
Open

Error: no init symbol for zero-initialized struct #4751

Zoadian opened this issue Sep 10, 2024 · 1 comment

Comments

@Zoadian
Copy link

Zoadian commented Sep 10, 2024

import std.stdio;
import core.stdc.config;

void main() {
__c_complex_float[] xxx = new __c_complex_float[10];
writeln(xxx);
}

results in "Error: no init symbol for zero-initialized struct".
it works with dmd.

@kinke
Copy link
Member

kinke commented Sep 14, 2024

Thx for the report. This boils down to:

import core.stdc.config;

void foo() {
    __c_complex_float x;
    x = typeof(x).init; // ICE - frontend incorrectly lowers it to the non-existent init symbol
}

Without that magic struct enum (enum __c_complex_float : _Complex!float;), all works fine, because .init is correctly lowered to a literal:

import core.stdc.config;

void foo() {
    _Complex!float x;
    x = typeof(x).init; // fine, assignment to a zero-initialized literal
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants