www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7629] New: Add check for ref/out parameters not being null

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

           Summary: Add check for ref/out parameters not being null
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



---
---
void f(ref int i) { }
void g(out int i) { }

void main()
{
    int* ptr = null;
    f(*ptr); // No RT errors
    g(*ptr); // `Access violation` because of a try to write a default value
}
---
Tests for ref/out parameters not being null will be very useful.

Current specs doesn't prohibit null ref/out parameters but it looks
inconsistent. I'd like specs to be changed to prohibit such cases or to clarify
why is it useful (and not prohibited).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7629




---
I meant the issue is that if ref null argument isn't used no RT error is
generated, `Access violation` for null out argument isn't perfect but is
acceptable and corresponds to member function call on null object reference.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2012