[Issue 2206] New: unnamed template mixin of class inside function or class has incorrect classinfo and mangleof
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 8 12:16:53 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2206
Summary: unnamed template mixin of class inside function or class
has incorrect classinfo and mangleof
Product: D
Version: 1.029
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: kamm-removethis at incasoftware.de
Test:
--
template T() {
class C {}
}
void main()
{
mixin T!(); // using a named mixin here fixes it
pragma(msg, T!().C.mangleof);
pragma(msg, C.mangleof); // incorrectly outputs the same as above
assert(T!().C.classinfo !is C.classinfo); // fails
assert(T!().C.mangleof != C.mangleof); // fails
}
--
The types of T!().C and main.C are clearly different as the nested one carries
an additional context pointer. This means that allocation relying on
classinfo.init.length should be wrong too.
In the frontend the types are initially different and only merged into a single
type during semantic. To be specific, Type::mangle unifies them as toDecoBuffer
yields the same result for both.
Maybe this could be fixed by adding a TemplateMixin::mangle overload. This
frontend bug causes some template-mixin related bugs in LLVMDC that seem to be
worked around somehow in DMD.
--
More information about the Digitalmars-d-bugs
mailing list