Bug 10630 – Structs with disabled default construction can't be used as `out` parameters

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-13T08:27:00Z
Last change time
2013-09-15T00:16:55Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-07-13T08:27:41Z
--- struct S { @disable this(); } void f(out S) { } // no errors here void main() { S s = S.init; f(s); // Error: struct main.S default construction is disabled } --- As disabled default construction may be also interpreded as "not for `out` parameters" (and yes, it breaks the code) it is absolutely inconsistent that the error is in function usage but not in the declaration.
Comment #1 by hsteoh — 2013-08-30T11:22:21Z
This has been a regression since at least 2.063.2. git bisect shows that the bad commit was: 0275c56cbaa09d6ec49e978bd011eb5b0a9b62aa Merge pull request #2052 from 9rnsr/fix10115 Issue 10115 - More @disabled holes
Comment #2 by k.hara.pg — 2013-09-01T18:53:16Z
(In reply to comment #1) > This has been a regression since at least 2.063.2. git bisect shows that the > bad commit was: > > 0275c56cbaa09d6ec49e978bd011eb5b0a9b62aa > Merge pull request #2052 from 9rnsr/fix10115 > > Issue 10115 - More @disabled holes This is not a true regression, because the combination of out parameter + disabled default construction struct is essentially invalid. http://dlang.org/function#parameters "parameter is initialized upon function entry with the default value for its type" Such struct does not have "default value", because its construction always needs explicit constructor call with one or more arguments. From 2.063, such function call was made invalid, but the declaration is still accepted. Therefore this issue should be marked an "accepts-invalid". Compiler fix: https://github.com/D-Programming-Language/dmd/pull/2510
Comment #3 by github-bugzilla — 2013-09-15T00:16:36Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6cb33db03031a48e5767072271f02d271dd21f28 fix Issue 10630 - Structs with disabled default construction can't be used as `out` parameters https://github.com/D-Programming-Language/dmd/commit/2b7b591296f63fdd344dd545a7b41ff53fa5b4ca Merge pull request #2510 from 9rnsr/fix10630 Issue 10630 - Structs with disabled default construction can't be used as `out` parameters