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

DMD segfaults with static array length parameter derived from left-shifted template parameter property #20907

Open
Herringway opened this issue Feb 21, 2025 · 2 comments · Fixed by #20919
Labels
Severity:ICE Internal Compiler Error

Comments

@Herringway
Copy link
Contributor

struct Bar { enum bar = 1; }
void foo(A)(A[], A[1 << A.bar]) {}
void main() {
    foo((Bar[]).init, (Bar[2]).init);
}

Segfaults with DMD 2.109.1 on both win32 and linux. Note that Bar.bar doesn't actually have to be present for this to segfault:

struct Bar {}
void foo(A)(A[], A[1 << A.bar]) {}
void main() {
    foo((Bar[]).init, (Bar[2]).init);
}
@thewilsonator thewilsonator added the Severity:ICE Internal Compiler Error label Feb 21, 2025
@dkorpel
Copy link
Contributor

dkorpel commented Feb 21, 2025

I see the segfault on run.dlang.org, but locally I get with DMD64 D Compiler v2.109.1:

testice.d(2): Error: integer constant expression expected instead of `1 << A.bar`

And with dmd master, it passes. Is this specific to 32-bit?

@Herringway
Copy link
Contributor Author

Ah, sorry for the omission. It was 64-bit. Though I seem to get the same result with -m32.

dkorpel added a commit to dkorpel/dmd that referenced this issue Feb 27, 2025
…rived from left-shifted template parameter property
dkorpel added a commit that referenced this issue Feb 28, 2025
… from left-shifted template parameter property (#20919)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Severity:ICE Internal Compiler Error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants