On 20/10/2010, at 1:33 AM, john skaller wrote: > This program crashes: > > //------- > noinline proc f() { > var p = C_hack::cast[&(string * string)] (C_hack::xnew("Hello","World")); > println$ *p; > } > > f(); > collect(); > println$ "Done"; > //-----
well now, here is the problem: ~/felix>build/release-optimized/bin/flx --test=build/release-optimized/ --force --nofelix tgc ('Hello', 'World') Finalising at 0x1001005a0 for 2 objects type _at9100 size 16 Try to finalise string at 0x1001005a0=Hello Size of string is 8 Size of void* is 8 Try to finalise string at 0x1001005b0=(null) Size of string is 8 Size of void* is 8 Felix is adding 16 to the pointer to get the next string.. that's the size of the whole array, not the size of one element.. simple! BTW: I do NOT understand how the size of a string can possibly be 8 on a 64 bit machine. I mean I do: it has to be a pointer to a control block: struct { int size; char *data; } but this just means an extra malloc when passing by value. Pass by reference would be faster but idiomatic (normally you'd pass a pointer to the variable in question, but here you pass the actual value). Ugg. The copy constructor will be very slow. I really don't understand this. -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language