Bug 13427 – [REG2.066] cannot inline default argument alloca(...)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-05T23:20:00Z
Last change time
2015-02-18T03:36:29Z
Keywords
pull, rejects-valid
Assigned to
yebblies
Creator
Marco.Leise

Comments

Comment #0 by Marco.Leise — 2014-09-05T23:20:10Z
A trick that Andrei and I came up with not long ago, to use alloca as part of a default argument does not work any more. I developed this with someone on #D one night and use it everywhere I need to pass a D string to a C API. Use cases: http://forum.dlang.org/thread/[email protected]#post-i1gql2:241k6o:241:40digitalmars.com https://github.com/mleise/fast/blob/master/source/fast/cstring.d#L92 ---------------8<---------------- import core.stdc.stdlib; enum allocaLimit = 1024; auto wcharPtr(alias str)(void* buffer = 2*(str.length+1) <= allocaLimit ? alloca(2*(str.length+1)) : null) { // ... } void main() { wcharPtr!"abc"w; } ------------->8----------------
Comment #1 by dlang-bugzilla — 2014-09-07T13:00:03Z
Introduced in https://github.com/D-Programming-Language/dmd/pull/3811 , which fixed issue 12820. Looks like it may have been intentional.
Comment #2 by Marco.Leise — 2014-09-07T13:09:58Z
(In reply to Vladimir Panteleev from comment #1) > Introduced in https://github.com/D-Programming-Language/dmd/pull/3811 , > which fixed issue 12820. Looks like it may have been intentional. In terms of what that pull fixed, namely bug https://issues.dlang.org/show_bug.cgi?id=12820 , it is a false positive. The alloca() call in this regression is not inside the function, but on the caller side where the default arguments are filled in. So it is (or at least I understand it like that) semantically equivalent to: wcharPtr!"abc"w(alloca(123));
Comment #3 by yebblies — 2014-09-07T13:31:38Z
Comment #4 by code — 2014-09-07T15:41:42Z
I think that somebody might have been me. CCing myself.
Comment #5 by github-bugzilla — 2014-09-07T18:36:29Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/94cb17dc63d0ee032b9db6b641a507162d48c4d2 Fix Issue 13427 - [REG2.066] cannot inline default argument alloca(...) https://github.com/D-Programming-Language/dmd/commit/0c20be0436317ce5ba6f34aaf23ea1eb429e1daf Merge pull request #3961 from yebblies/issue13427 Issue 13427 - [REG2.066] cannot inline default argument alloca(...)
Comment #6 by github-bugzilla — 2014-09-14T13:33:38Z
Commit pushed to 2.066 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/021b481b60ea16285e447b1d399e07ce2319e9cf Merge pull request #3961 from yebblies/issue13427 Issue 13427 - [REG2.066] cannot inline default argument alloca(...)
Comment #7 by github-bugzilla — 2015-02-18T03:36:29Z