[Issue 2328] New: setTypeInfo in gc.d backwards.
dsimcha
dsimcha at yahoo.com
Tue Sep 2 12:26:56 PDT 2008
== Quote from Sean Kelly (sean at invisibleduck.org)'s article
> d-bugmail at puremagic.com wrote:
> > http://d.puremagic.com/issues/show_bug.cgi?id=2328
> >
> > Summary: setTypeInfo in gc.d backwards.
> > Product: D
> > Version: 2.018
> > Platform: All
> > OS/Version: All
> > Status: NEW
> > Severity: major
> > Priority: P2
> > Component: Phobos
> > AssignedTo: bugzilla at digitalmars.com
> > ReportedBy: dsimcha at yahoo.com
> >
> >
> > According to Phobos object docs:
> >
> > uint flags();
> > Get flags for type: 1 means GC should scan for pointers
> >
> > This is implemented correctly.
> >
> > import std.stdio;
> >
> > void main() {
> > writefln(typeid(uint).flags & 1); //0
> > writefln(typeid(uint*).flags & 1); //1
> > writefln(typeid(void*).flags & 1); //1
> > writefln(typeid(float).flags & 1); //0
> > }
> >
> > However, source code to setTypeInfo:
> >
> > void setTypeInfo(TypeInfo ti, void* p)
> > {
> > if (ti.flags() & 1)
> > hasNoPointers(p);
> > else
> > hasPointers(p);
> > }
> >
> > The if statement in this code is clearly backwards.
> I'm fairly certain that the doc comment is simply wrong. Last time I
> checked, the flag was 1 for "has no pointers" as per the implementation.
> I'd actually prefer it to work as the comment suggests, however.
Nope, I actually tested the implementation. I didn't just assume the doc comment
was right. Furthermore, I tried to write code based on the expected behavior of
Phobos's setTypeInfo() and it was clearly broken. Lying to setTypeInfo() about
the type fixed it. Note that I don't know if this bug exists in Tango or
Phobos/D1, only that it does exist in Phobos/D2.
More information about the Digitalmars-d-bugs
mailing list