[Issue 19479] New: ints defined in template mixins have garbage values
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 12 06:59:36 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19479
Issue ID: 19479
Summary: ints defined in template mixins have garbage values
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: johannes.riecken at gmail.com
Code:
import std.conv;
import std.stdio;
mixin template genInts()
{
enum arr = [0,1];
static foreach (t; arr) {
mixin("int i" ~ to!string(t) ~ " = 5;");
}
}
void main() {
mixin genInts!();
writeln(i0);
writeln(i1);
}
Expected output:
5
5
Actual output is two garbage integer values.
$ dmd --version
DMD64 D Compiler v2.083.0
Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
written by Walter Bright
$ uname -a
Linux jo-FX80 4.19.4-arch1-1-ARCH #1 SMP PREEMPT Fri Nov 23 09:06:58 UTC 2018
x86_64 GNU/Linux
--
More information about the Digitalmars-d-bugs
mailing list