D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7629 - Add check for ref/out parameters not being null
Summary: Add check for ref/out parameters not being null
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-02 06:48 UTC by Denis Shelomovskii
Modified: 2024-12-13 17:58 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Denis Shelomovskii 2012-03-02 06:48:33 UTC
---
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).
Comment 1 Denis Shelomovskii 2012-03-02 07:51:54 UTC
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.
Comment 2 dlangBugzillaToGithub 2024-12-13 17:58:54 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17542

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB