digitalmars.D.bugs - two std.boxer bugs -- patch - boxer.patch
- derick_eddington nospam.yashmoo.com Jun 03 2005
If a null Object reference is box()'d and unboxable!(SubClass)(boxedNullObj) is
attempted, std.box.Box.unboxable tries to offset from null.
: import std.boxer, std.stdio;
:
: class Hmm {}
:
: void main ()
: {
: // need this to get TypeInfo for Hmm, else I get linker error
: if (typeid(Hmm) is null && false) writefln("never");
:
: Object nullObj;
: Box nullBox = box(nullObj);
:
: bool isUnBoxable = unboxable!(Hmm)(nullBox);
:
: writefln("isUnBoxable: %s", isUnBoxable);
: }
: $ ./boxbug
: Box.unboxable(Hmm) begin...
: this.type = Object this.data = 0xbffff2c0(4)[00,00,00,00,]
: both are classes, casting this.data to an Object reference...
: o is null: true
: Uncaught:
: SegmentationFault: unmapped address 0x00000000
After fixing this, I discovered another bug: 'template unbox (T : Object)' will
always return null if the boxed thing is a null-Object-reference regardless if
it should be unboxable as the requested type, causing 'template unboxTest (T)'
used in the unittest to fail.
(On a side note, bug
digitalmars.D.bugs/4172 is preventing
'bit fails (void delegate()func)' in the unittest from working, so you have to
do all the fails cases one by one.)
I've attached my patch.
Jun 03 2005








derick_eddington nospam.yashmoo.com