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

Bug in byref-return checking: passing local struct address should not be permitted #1401

Closed
dsyme opened this issue Aug 2, 2016 · 2 comments
Labels
Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.

Comments

@dsyme
Copy link
Contributor

dsyme commented Aug 2, 2016

This is a bug in ref-return safety checking, a missing error for negative test case https://github.com/Microsoft/visualfsharp/pull/1367/files#diff-59ae1d2137d6b7479475f5d1287557d9L13

For most cases of returning byrefs we correctly report an error, e,g

let negTest5() = 
    let mutable x = 0
    let addr = &x
    &addr

But not for this case:

Repro steps

Compile this code:

module Test

[<Struct>]
type Struct(initial:int) = 
    let mutable x = initial
    member __.AddrX = &x
    member __.IncrX() = x <- x + 1

let negTest7() = 
    let mutable iterator = Struct(0)
    iterator.AddrX

Expected behavior

We expect an error to be reported

Actual behavior

No error is reported

@dsyme dsyme added Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Area-Compiler labels Aug 2, 2016
@forki
Copy link
Contributor

forki commented Nov 25, 2016

image

nice one ;-)

@dsyme
Copy link
Contributor Author

dsyme commented Apr 29, 2017

Closing in favour of the bucket bug #862

@dsyme dsyme closed this as completed Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
None yet
Development

No branches or pull requests

2 participants