I think is a bug?

Random D user via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 11 17:51:04 PST 2017


int*[] foo;
foo.length = 5;

import std.c.string;
int* baz = cast(string*)malloc(50);

import std.c.stdio;
printf("%d %d", foo.length, baz.length );

prints:
Error: no property 'length' for type 'int*'

BUT:

string*[] foo;
foo.length = 5;

import std.c.string;
string* baz = cast(string*)malloc(50);

import std.c.stdio;
printf("%d %d", foo.length, baz.length );

compiles and prints:
5 -842150451

How come string* suddenly has a .length property?
Anyway the result is garbage, so I think this must be a bug.

DMD32 D Compiler v2.073.2


More information about the Digitalmars-d-learn mailing list