Bug 12436 – Opaque struct parameter type should not be allowed

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-21T15:21:00Z
Last change time
2014-05-28T18:33:29Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2014-03-21T15:21:38Z
----- struct Opaque; Opaque ret_func(); // ok: error void void_func(Opaque); // no error! ----- $ dmd test.d test.d(3): Error: cannot return opaque struct Opaque by value The void_func is not triggering errors, but it should.
Comment #1 by andrej.mitrovich — 2014-03-21T15:38:16Z
There are various other cases not caught yet, even for return types which are partially checked now. Examples: ----- struct S; S ret_f1(); // ok: fails S[] ret_f2(); // should fail S[1] ret_f4(); // should fail S[]* ret_f3(); // should fail void call_f1(S); // should fail void call_f1(S[]); // should fail void call_f1(S[1]); // should fail void call_f1(S[]*); // should fail void main() { } -----
Comment #2 by schveiguy — 2014-03-21T15:48:15Z
I would point out that references to opaque structs should compile. In your examples: S[] S[]* Should compile, even if S is opaque, as these are just references to S.
Comment #3 by andrej.mitrovich — 2014-03-21T17:09:08Z
(In reply to comment #2) > I would point out that references to opaque structs should compile. > > In your examples: > > S[] > S[]* > > Should compile, even if S is opaque, as these are just references to S. Yeah, my mistake.
Comment #4 by k.hara.pg — 2014-05-26T03:44:38Z
Comment #5 by github-bugzilla — 2014-05-28T18:33:28Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/eca6fa41ec1b37da850a30de16086f3f8b4b4e70 fix Issue 12436 - Opaque struct parameter type should not be allowed https://github.com/D-Programming-Language/dmd/commit/f15bd87f04b2f45cb43256f336156d8515facb46 Merge pull request #3584 from 9rnsr/fix12436 Issue 12436 - Opaque struct parameter type should not be allowed