Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
December 26, 2013 [Issue 11824] New: A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
https://d.puremagic.com/issues/show_bug.cgi?id=11824 Summary: A stack variable escaping problem in CTFE Phobos code Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-12-26 09:50:35 PST --- import std.array: array; import std.range: repeat; auto r = [1].repeat(1).array; void main() {} DMD 2.065alpha gives me: ...\dmd2\src\phobos\std\array.d(45): Error: returning a pointer to a local stack variable ...\dmd2\src\phobos\std\array.d(49): called from here: trustedGetAddr(result[i]) ...\dmd2\src\phobos\std\array.d(49): called from here: emplace(trustedGetAddr(result[i]), e) test.d(3): called from here: array(repeat([1], 1u)) -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com Severity|normal |regression --- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-02-03 17:47:33 EET --- I have encountered the same problem: import std.algorithm; import std.array; auto f(int arr) { return [5]; } immutable x = [1].map!f.array(); This is a regression from 2.064.2. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 --- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-02-03 17:57:23 EET --- Introduced in https://github.com/D-Programming-Language/phobos/pull/1655 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra@gmail.com --- Comment #3 from monarchdodra@gmail.com 2014-02-03 08:11:37 PST --- (In reply to comment #2) > Introduced in https://github.com/D-Programming-Language/phobos/pull/1655 The fix is trivial, I'll push it tonight. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |CTFE --- Comment #4 from monarchdodra@gmail.com 2014-02-03 09:27:55 PST --- I can work *around* the issue, but there is a CTFE bug in there to begin with. Here is a reduced test case: //---- int foo(T)() { T[] arr = new T[](1); T* getAddr(ref T a) { return &a; } getAddr(arr[0]); return 5; } void main() { enum a = foo!int(); //OK! enum b = foo!(int[])(); //FAILS! } //---- main.d(6): Error: returning a pointer to a local stack variable main.d(8): called from here: getAddr(arr[0]) main.d(15): called from here: foo() //---- First of all: "foo()" ? What are the template parameters? Second, I *think* there is a rejects valid: getAddr rejects "return &a" if a is of type "T[]", but not "T". To be perfectly pedantic: a happens to be a stack variable, yes, but *not* inside "getAddr" 's scope. So this should not be rejected during CTFE I think. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 04, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Component|Phobos |DMD Platform|x86 |All OS/Version|Windows |All --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2014-02-03 21:52:04 PST --- (In reply to comment #4) > I can work *around* the issue, but there is a CTFE bug in there to begin with. > [snip] > To be perfectly pedantic: a happens to be a stack variable, yes, but *not* inside "getAddr" 's scope. So this should not be rejected during CTFE I think. Yes, this is a compiler bug. https://github.com/D-Programming-Language/dmd/pull/3204 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 07, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 --- Comment #6 from github-bugzilla@puremagic.com 2014-02-06 16:26:12 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/dc828cccfe92b98d3ae334eedd082d4f04cf36c1 fix Issue 11824 - A stack variable escaping problem in CTFE Phobos code https://github.com/D-Programming-Language/dmd/commit/cbc100abebbc5db94af1f173daa602e1f5a7e317 Merge pull request #3204 from 9rnsr/fix11824 [REG2.065a] Issue 11824 - A stack variable escaping problem in CTFE Phobos code -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 07, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 27, 2014 [Issue 11824] A stack variable escaping problem in CTFE Phobos code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | https://d.puremagic.com/issues/show_bug.cgi?id=11824 --- Comment #7 from monarchdodra@gmail.com 2014-02-27 04:25:33 PST --- *** Issue 11428 has been marked as a duplicate of this issue. *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation