[Issue 14696] destructor for temporary called before statement is complete with conditional operator

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jun 17 05:39:10 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14696

--- Comment #8 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
(In reply to Walter Bright from comment #3)
>     this(int i) {
>         c = 's';
>         p = &c;
>     }

compiler should play a crybaby here, as storing pointer to struct field is not
valid for non-heap-allocated structs. considering that most structs are
non-heap, i prefer to see at least a warning. which, for example, can be
silenced with explicit cast: `p = cast(char*)&c;`. or even with some library
function like `p = (&c).assumeCorrect;`

--


More information about the Digitalmars-d-bugs mailing list