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.