www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - unbox!(char[]) fails with linker error.

reply Fredrik Olsson <peylow gmail.com> writes:
Hi.

This tiny test:

// !!! Begin unboxfail.d !!!
import std.boxer;
import std.stdio;

int main(char[][]args)
{
     Box b = box("Hello World");
     if (unboxable!(char[])(b)) {
         writefln(unbox!(char[])(b));    // !!! Fails !!!
         return 0;
     } else {
         return 1;
     }
}
!!! End unboxfail.d

Compiled with:
gdc unboxfail.d -o unboxfail

Gives this error message:
ld: Undefined symbols:
__init_11TypeInfo_Pv


I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. 
I run under Mac OS X 1.4.2.

Is there a special trick to unboxing arrays, or have I stumbled upon a bug?

regards
	Fredrik Olsson
Aug 04 2005
parent reply Victor Nakoryakov <nail-mail mail.ru> writes:
Fredrik Olsson wrote:
 Hi.
 
 This tiny test:
 
 // !!! Begin unboxfail.d !!!
 import std.boxer;
 import std.stdio;
 
 int main(char[][]args)
 {
     Box b = box("Hello World");
     if (unboxable!(char[])(b)) {
         writefln(unbox!(char[])(b));    // !!! Fails !!!
         return 0;
     } else {
         return 1;
     }
 }
 !!! End unboxfail.d
 
 Compiled with:
 gdc unboxfail.d -o unboxfail
 
 Gives this error message:
 ld: Undefined symbols:
 __init_11TypeInfo_Pv
 
 
 I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. 
 I run under Mac OS X 1.4.2.
 
 Is there a special trick to unboxing arrays, or have I stumbled upon a bug?
 
 regards
     Fredrik Olsson
This is a bug and it already added to DStress. -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russia
Aug 05 2005
parent reply Fredrik Olsson <peylow gmail.com> writes:
Victor Nakoryakov wrote:
 Fredrik Olsson wrote:
 
 Hi.

 This tiny test:

 // !!! Begin unboxfail.d !!!
 import std.boxer;
 import std.stdio;

 int main(char[][]args)
 {
     Box b = box("Hello World");
     if (unboxable!(char[])(b)) {
         writefln(unbox!(char[])(b));    // !!! Fails !!!
         return 0;
     } else {
         return 1;
     }
 }
 !!! End unboxfail.d

 Compiled with:
 gdc unboxfail.d -o unboxfail

 Gives this error message:
 ld: Undefined symbols:
 __init_11TypeInfo_Pv


 I use gdc 0.15 installed from Anders F Björklund's package for Mac OS 
 X. I run under Mac OS X 1.4.2.

 Is there a special trick to unboxing arrays, or have I stumbled upon a 
 bug?

 regards
     Fredrik Olsson
This is a bug and it already added to DStress.
Good. Is there a work-around that can be used in the mean time (I need to box and unbox int, float, char[] and my own class Block and it's decendant ContainerBlock only). Regards Fredrik Olsson
Aug 05 2005
parent reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
Fredrik Olsson wrote:
 Victor Nakoryakov wrote:
 
 Fredrik Olsson wrote:

 Hi.

 This tiny test:

 // !!! Begin unboxfail.d !!!
 import std.boxer;
 import std.stdio;

 int main(char[][]args)
 {
     Box b = box("Hello World");
     if (unboxable!(char[])(b)) {
         writefln(unbox!(char[])(b));    // !!! Fails !!!
         return 0;
     } else {
         return 1;
     }
 }
 !!! End unboxfail.d

 Compiled with:
 gdc unboxfail.d -o unboxfail

 Gives this error message:
 ld: Undefined symbols:
 __init_11TypeInfo_Pv


 I use gdc 0.15 installed from Anders F Björklund's package for Mac OS 
 X. I run under Mac OS X 1.4.2.

 Is there a special trick to unboxing arrays, or have I stumbled upon 
 a bug?

 regards
     Fredrik Olsson
This is a bug and it already added to DStress.
Good. Is there a work-around that can be used in the mean time (I need to box and unbox int, float, char[] and my own class Block and it's decendant ContainerBlock only). Regards Fredrik Olsson
I would assume you can write something like this: <code> class StringBox { this( char str[] ) { // .. do something to encapsulate str into this object } } Box x = ( new StringBox("HelloWorld") ); </code> i.e. write a small class or struct that hides the string, and then box that class and unbox it.
Aug 05 2005
parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
Hasan Aljudy wrote:
 Fredrik Olsson wrote:
 
 Victor Nakoryakov wrote:

 Fredrik Olsson wrote:

 Hi.

 This tiny test:

 // !!! Begin unboxfail.d !!!
 import std.boxer;
 import std.stdio;

 int main(char[][]args)
 {
     Box b = box("Hello World");
     if (unboxable!(char[])(b)) {
         writefln(unbox!(char[])(b));    // !!! Fails !!!
         return 0;
     } else {
         return 1;
     }
 }
 !!! End unboxfail.d

 Compiled with:
 gdc unboxfail.d -o unboxfail

 Gives this error message:
 ld: Undefined symbols:
 __init_11TypeInfo_Pv


 I use gdc 0.15 installed from Anders F Björklund's package for Mac 
 OS X. I run under Mac OS X 1.4.2.

 Is there a special trick to unboxing arrays, or have I stumbled upon 
 a bug?

 regards
     Fredrik Olsson
This is a bug and it already added to DStress.
Good. Is there a work-around that can be used in the mean time (I need to box and unbox int, float, char[] and my own class Block and it's decendant ContainerBlock only). Regards Fredrik Olsson
I would assume you can write something like this: <code> class StringBox { this( char str[] ) { // .. do something to encapsulate str into this object } } Box x = ( new StringBox("HelloWorld") ); </code> i.e. write a small class or struct that hides the string, and then box that class and unbox it.
woops, I meant: #Box b = box( new StringBox("HelloWorld") );
Aug 05 2005