std.json segmentation fault
Stephan
stephan_schiffels at mac.com
Wed Feb 6 01:41:27 PST 2013
On Monday, 4 February 2013 at 10:04:10 UTC, Andrea Fontana wrote:
> This code was working some months ago:
>
> import std.json;
> JSONValue total;
> total.type = JSON_TYPE.OBJECT;
> total["results"].type = JSON_TYPE.OBJECT;
>
>
> Now, last line gives me a segmentation fault. What's wrong with
> this code?
Here is a full test case. I don't want to submit it to Bugzilla
yet, since I don't know whether it's intended behaviour or a bug.
I have a slight feeling that this is NOT a bug. Somehow, in the
first case a reference to an invalid struct is returned by
json["hello"] and attempted to be overridden by a new JSONValue.
In the second case, no reference is generated, instead a simple
struct copy (a blit) is invoked, which works. Can someone explain
this more correctly?
This program crashes (tested on dmd 2.061)
import std.json;
void main() {
JSONValue json;
json.type = JSON_TYPE.OBJECT;
json["hello"] = JSONValue();
}
This program works fine:
import std.json;
void main() {
JSONValue json;
json.type = JSON_TYPE.OBJECT;
json.object["hello"] = JSONValue();
}
More information about the Digitalmars-d
mailing list