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

NewPlist used incorrectly in to_gap method #119

Closed
fingolfin opened this issue Nov 1, 2018 · 3 comments
Closed

NewPlist used incorrectly in to_gap method #119

fingolfin opened this issue Nov 1, 2018 · 3 comments
Assignees
Labels
kind: bug Something isn't working

Comments

@fingolfin
Copy link
Member

The following code creates a plist of capacity length(v) but size 0 (!), then fills it, but never sets the length.

function to_gap(v :: Array{T, 1} where T) :: MPtr
    l = NewPlist(length(v))
    for i in 1:length(v)
        l[i] = v[i]
    end
    return l
end
@fingolfin fingolfin added the kind: bug Something isn't working label Nov 1, 2018
@sebasguts
Copy link
Contributor

We need to set it in the NewPlistconstructor in libgap. See gap-system/gap#2963

@sebasguts
Copy link
Contributor

Okay, when investigating this, the list seems to be all right. [] uses ASS_LIST, so it should set the length correctly:

julia> xx=[1]
1-element Array{Int64,1}:
 1

julia> GAP.to_gap(xx)
GAP: [ 1 ]

julia> x = GAP.to_gap(xx)
GAP: [ 1 ]

julia> GAP.GAPFuncs.Length(x)
1

@fingolfin
Copy link
Member Author

Indeed, I was totally wrong. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants