www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12436] New: Opaque struct parameter type should not be allowed

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12436

           Summary: Opaque struct parameter type should not be allowed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-21
15:21:38 PDT ---
-----
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 21 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12436



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-21
15:38:16 PDT ---
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() { }
-----

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 21 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12436


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy yahoo.com


--- Comment #2 from Steven Schveighoffer <schveiguy yahoo.com> 2014-03-21
15:48:15 PDT ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 21 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12436



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-21
17:09:08 PDT ---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 21 2014