[Issue 20758] New: __traits(getAttributes) as template argument results in broken template instances
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 22 10:45:02 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20758
Issue ID: 20758
Summary: __traits(getAttributes) as template argument results
in broken template instances
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: maxsamukha at gmail.com
template foo(a...) {
static int x;
}
void attr1() {}
// enum attr2 = 1;
// struct attr3 {}
@attr1 int x;
alias f1 = foo!attr1;
alias f2 = foo!(__traits(getAttributes, x));
// passes
static assert(f1.mangleof == f2.mangleof);
// fails, should pass
static assert(__traits(isSame, f1, f2));
void main() {
auto p1 = &f1.x;
auto p2 = &f2.x;
// passes
assert(p1 == p2);
// but this fails
assert(&f1.x == &f2.x);
}
The bug seems to manifest only for attributes that are functions. If attr1 is
replaced with attr2 or attr3, the assertions pass.
--
More information about the Digitalmars-d-bugs
mailing list