D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7230 - Crash during printing anonymous union with writeln family functions.
Summary: Crash during printing anonymous union with writeln family functions.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: patch
: 7324 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-01-05 02:28 UTC by Lukasz Wrzosek
Modified: 2012-03-25 03:18 UTC (History)
2 users (show)

See Also:


Attachments
bug test case (157 bytes, text/x-dsrc)
2012-01-05 02:30 UTC, Lukasz Wrzosek
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Lukasz Wrzosek 2012-01-05 02:28:54 UTC
writeln is not aware of anonymous unions inside of structs (probably classes too).

The attached file crashes when run.
Comment 1 Lukasz Wrzosek 2012-01-05 02:30:33 UTC
Created attachment 1068 [details]
bug test case
Comment 2 bearophile_hugs 2012-01-05 02:38:21 UTC
Code copied here to increase its visibility:


import std.stdio;
struct Bug7230 {
    union {
        string a;
        int b;
    }
}
void main() {
    Bug7230 bug;
    bug.b = 123;
    writeln(bug);
}
Comment 3 Kenji Hara 2012-01-06 12:36:45 UTC
https://github.com/D-Programming-Language/phobos/pull/383

The format implemented the patch is not yet determined.
Please comment your opinion.
Comment 4 bearophile_hugs 2012-01-06 13:31:11 UTC
(In reply to comment #3)
> https://github.com/D-Programming-Language/phobos/pull/383
> 
> The format implemented the patch is not yet determined.
> Please comment your opinion.

Thank you for improving writeln.

Maybe the string tag "union" is better than "overlap":
Bug7230("hello", #{union a, b, c}, 10)
Comment 6 Kenji Hara 2012-03-25 03:18:02 UTC
*** Issue 7324 has been marked as a duplicate of this issue. ***