Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record copy constructor should be protected #44897

Closed
cston opened this issue Jun 5, 2020 · 2 comments · Fixed by #45022
Closed

Record copy constructor should be protected #44897

cston opened this issue Jun 5, 2020 · 2 comments · Fixed by #45022
Assignees
Milestone

Comments

@cston
Copy link
Member

cston commented Jun 5, 2020

The copy constructor is currently public which means it can be referenced unintentionally.

record A;
record B(object P) : A;

class Program
{
    static void Main()
    {
        _ = new B(null); // NullReferenceException calling B.B(B) rather than B.B(object)
    }
}
@cston cston added this to the 16.7 milestone Jun 5, 2020
@jcouv
Copy link
Member

jcouv commented Jun 6, 2020

Relates to #44902 (derived copy constructor should leverage base copy constructor)

@jcouv
Copy link
Member

jcouv commented Jun 15, 2020

Fix merged into 16.7p3. Closing this

@jcouv jcouv closed this as completed Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants