digitalmars.D.learn - Bug on dmd or gdc ?
- Domingo Alvarez Duarte (27/27) Jul 27 2014 Hello !
- bearophile (7/15) Jul 28 2014 I guess you are using different versions of the front-end.
- Domingo Alvarez Duarte (3/19) Jul 28 2014 Thanks ! You are right I'm using dmd 2.066 and gdc 4.8/4.9,
Hello !
Based on a question about manually allocated structures with
payload I found that a solution proposed seems to work when
compiled with dmd but segfaults when compiled with gdc.
So my question is: Is this a bug on dmd, gdc or a bad idiom ?
---- code to see the problem
import std.stdio;
import core.stdc.stdlib;
void main()
{
struct S
{
int size;
char[0] _b;
property char[] buf() { return (_b.ptr)[0..size];}
}
int size = 12;
S *s = cast(S*)malloc(S.sizeof + size);
if(s !is null)
{
scope(exit) free(s);
s.size = size;
s.buf[0] = 'a';
writeln(s.buf[0]);
}
}
Jul 27 2014
Domingo Alvarez Duarte:
Based on a question about manually allocated structures with
payload I found that a solution proposed seems to work when
compiled with dmd but segfaults when compiled with gdc.
...
int size;
char[0] _b;
property char[] buf() { return (_b.ptr)[0..size];}
}
I guess you are using different versions of the front-end.
Zero-length arrays was null before, and it's not null in V. 2.066.
So probably there is no bug, just a little design change for the
better.
Bye,
bearophile
Jul 28 2014
On Monday, 28 July 2014 at 08:16:37 UTC, bearophile wrote:Domingo Alvarez Duarte:Thanks ! You are right I'm using dmd 2.066 and gdc 4.8/4.9, Cheers !Based on a question about manually allocated structures with payload I found that a solution proposed seems to work when compiled with dmd but segfaults when compiled with gdc. ... int size; char[0] _b; property char[] buf() { return (_b.ptr)[0..size];} }I guess you are using different versions of the front-end. Zero-length arrays was null before, and it's not null in V. 2.066. So probably there is no bug, just a little design change for the better. Bye, bearophile
Jul 28 2014








"Domingo Alvarez Duarte" <mingodad gmail.com>