Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 14, 2015 [Issue 14696] destructor for temporary called before statement is complete with ternary operator and alias this | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 --- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> --- the same bug on HEAD without an alias: //alias get this; ... foo(args.length ? makes().get : null); -- |
June 15, 2015 [Issue 14696] destructor for temporary called before statement is complete with ternary operator and alias this | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 --- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> --- (In reply to Ketmar Dark from comment #1) > the same bug on HEAD without an alias: > > //alias get this; > ... > foo(args.length ? makes().get : null); And the obvious smacks me in the face :) Thanks. -- |
June 16, 2015 [Issue 14696] destructor for temporary called before statement is complete with ternary operator and alias this | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- A simpler demonstration: import core.stdc.stdio; struct S { this(int i) { c = 's'; p = &c; } ~this() { printf("S.dtor\n"); c = 'd'; } char *p; char c = 's'; } int main() { char t = 't'; char *q = &t; int x = 1; char *p = x ? S(1).p : q; printf("*p = %c\n", *p); assert(*p == 's'); return 0; } -- |
June 16, 2015 [Issue 14696] destructor for temporary called before statement is complete with ternary operator and alias this | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 --- Comment #4 from Steven Schveighoffer <schveiguy@yahoo.com> --- (In reply to Walter Bright from comment #3) > struct S { > this(int i) { > c = 's'; > p = &c; This is not allowed, and I'm not sure it's a valid test case. You could fix by doing this: struct S { this(ref char x){ p = &x; *p = 's'; } ~this() { if(p) *p = 'd'; p = null; } } void main() { char c = 'c'; char o = 'o'; int i = 1; writeln(*(i ? S(c).p : &o)); } prints: d -- |
June 17, 2015 [Issue 14696] destructor for temporary called before statement is complete with ternary operator and alias this | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 Yuxuan Shui <yshuiv7@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yshuiv7@gmail.com --- Comment #5 from Yuxuan Shui <yshuiv7@gmail.com> --- I think this one might be related: #14653 -- |
June 17, 2015 [Issue 14696] destructor for temporary called before statement is complete with ternary operator and alias this | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 --- Comment #6 from Yuxuan Shui <yshuiv7@gmail.com> --- (In reply to Yuxuan Shui from comment #5) > I think this one might be related: #14653 https://issues.dlang.org/show_bug.cgi?id=14653 -- |
June 17, 2015 [Issue 14696] destructor for temporary called before statement is complete with conditional operator | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Summary|destructor for temporary |destructor for temporary |called before statement is |called before statement is |complete with ternary |complete with conditional |operator and alias this |operator --- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> --- https://github.com/D-Programming-Language/dmd/pull/4749 -- |
June 17, 2015 [Issue 14696] destructor for temporary called before statement is complete with conditional operator | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 --- Comment #8 from Ketmar Dark <ketmar@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;` -- |
June 17, 2015 [Issue 14696] destructor for temporary called before statement is complete with conditional operator | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 --- Comment #9 from Ketmar Dark <ketmar@ketmar.no-ip.org> --- (In reply to Yuxuan Shui from comment #5) > I think this one might be related: #14653 it is related in the sense that it doesn't do struct dtor in the right place, but the exact place where it is failed is different. ;-) -- |
August 31, 2015 [Issue 14696] destructor for temporary called before statement is complete with conditional operator | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=14696 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |14979 -- |
Copyright © 1999-2021 by the D Language Foundation