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

Variadic template alignment incorrect #20733

Open
HuskyNator opened this issue Jan 18, 2025 · 2 comments
Open

Variadic template alignment incorrect #20733

HuskyNator opened this issue Jan 18, 2025 · 2 comments

Comments

@HuskyNator
Copy link

I'm unaware of the implementation details, but using variadic templates seemingly causes alignment issues.

Example:

import std.stdio;

struct A(T) {
    T a;
    this(size_t L, size_t R)(T[L] left, T[R] right...) if (L + R == 4) {
        this.a = right[0];
    }
}

void main() {
    A!float a = A!float([1, 2, 3], 0);
    writeln(a.a); // 2 (not 0!)
}

Environment

Version: DMD v2.190.1 (Works fine on 2.190.0 and ldc2)
Platform: Windows 64 bits


SideNote:

How come I cannot assign lables/types to this issue?
Would be useful.

@thewilsonator
Copy link
Contributor

Version: DMD v2.190.1 (Works fine on 2.190.0 and ldc2)

I assume you mean 2.109.1 not 2.190.1.

How come I cannot assign lables/types to this issue?

Because you are not a member of this repository.

writeln(a.a); // 2 (not 0!)

are you saying that this prints 2? for me on run.dlang.io this prints 0. What I observe is what I would expect to happen.

@HuskyNator
Copy link
Author

That is correct, 2.190.1. Indeed it prints 0 on run.dlang.io.
@pbackus told me this was because run.dlang.io is using 2.190.0, also stating the latest commit dmd master version also prints 0 (I'm currently unable to confirm)

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