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

Digraphs uses NEW_PLIST_WITH_MUTABILITY which is not present in GAP 4.9.0 #266

Closed
james-d-mitchell opened this issue Oct 16, 2019 · 3 comments
Assignees
Labels
bug A label for issues that are bugs resolved-pending-release A label for issues that have been resolved and that can be closed when a new version is released.

Comments

@james-d-mitchell
Copy link
Member

Apparently, in v1.0.1, if I try to compile Digraphs with GAP v4.9.0 and I get the following warnings:

src/digraphs.c:88:13: warning: implicit declaration of function
      'NEW_PLIST_WITH_MUTABILITY' is invalid in C99
      [-Wimplicit-function-declaration]
      ret = NEW_PLIST_WITH_MUTABILITY(mut, T_PLIST_EMPTY, 0);
            ^
src/digraphs.c:88:11: warning: incompatible integer to pointer conversion
      assigning to 'Obj' (aka 'unsigned long long **') from 'int'
      [-Wint-conversion]
      ret = NEW_PLIST_WITH_MUTABILITY(mut, T_PLIST_EMPTY, 0);
          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/digraphs.c:90:13: warning: implicit declaration of function
      'NEW_PLIST_WITH_MUTABILITY' is invalid in C99
      [-Wimplicit-function-declaration]
      ret = NEW_PLIST_WITH_MUTABILITY(mut, T_PLIST_TAB, n);
            ^
src/digraphs.c:90:11: warning: incompatible integer to pointer conversion
      assigning to 'Obj' (aka 'unsigned long long **') from 'int'
      [-Wint-conversion]
      ret = NEW_PLIST_WITH_MUTABILITY(mut, T_PLIST_TAB, n);
          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/digraphs.c:126:1: warning: control may reach end of non-void function
      [-Wreturn-type]
}

And indeed NEW_PLIST_WITH_MUTABILITY does not exist in GAP v4.9.0. This should be easy to fix.

@james-d-mitchell james-d-mitchell added the bug A label for issues that are bugs label Oct 17, 2019
@james-d-mitchell james-d-mitchell self-assigned this Oct 17, 2019
@james-d-mitchell james-d-mitchell added this to the 1.0.2 milestone Oct 17, 2019
@wilfwilson
Copy link
Collaborator

Thanks for noticing this @james-d-mitchell. I'm curious why this isn't actually causing any of our tests to fail. (We test the required version of GAP, currently 4.9.0, in one Travis job, e.g. https://travis-ci.org/gap-packages/Digraphs/jobs/598715505).

Do you think that means we have no coverage of these lines? Or is something else going on?

@james-d-mitchell
Copy link
Member Author

Yeah I noticed this too, it must mean that those lines of code aren't tested, or they are and something more complicated is going on...

@wilfwilson
Copy link
Collaborator

wilfwilson commented Oct 17, 2019

I think this code is never executed. I thought I could trigger the relevant code by creating a digraph via source and range, and then asking for the out-neighbours. When I create such a digraph, it claims not to know its out-neighbours, but in fact they are already known and stored in its OutNeighbours record component:

gap> r := rec(DigraphNrVertices := 0, DigraphRange := [], DigraphSource := []);;
gap> D := Digraph(r);;
gap> HasOutNeighbours(D);
false
gap> NamesOfComponents(D);
[ "DigraphNrEdges", "OutNeighbours" ]

This is because digraphs are ultimately (as far as I can tell) created via the following code, which directly constructs the out-neighbours from the source-and range using the separate function DIGRAPH_OUT_NEIGHBOURS_FROM_SOURCE_RANGE:

InstallMethod(DigraphConsNC, "for IsMutableDigraph and a record",
[IsMutableDigraph, IsRecord],
function(filt, record)
  [...omitted...]
  out := DIGRAPH_OUT_NEIGHBOURS_FROM_SOURCE_RANGE(record.DigraphNrVertices,
                                                  record.DigraphSource,
                                                  record.DigraphRange);
  return ConvertToMutableDigraphNC(out);
end);

I think this means that anything that is a digraph object already necessarily knows its OutNeighbours. Therefore the C function FuncOutNeighbours on digraphs.c:76 always returns on its second line, and never reaches the problematic code.

That explains why this use of NEW_PLIST_WITH_MUTABILITY is not breaking anything. So should we simply remove this code now? (And think about getting automated code coverage for our kernel code...)

@wilfwilson wilfwilson changed the title Digraphs no longer works with GAP 4.9.0 Digraphs uses NEW_PLIST_WITH_MUTABILITY which is not present in GAP 4.9.0 Oct 17, 2019
wilfwilson added a commit to wilfwilson/Digraphs that referenced this issue Nov 12, 2019
@wilfwilson wilfwilson added the resolved-pending-merge A label for issues that are resolved in a PR that is not yet merged. label Nov 12, 2019
@wilfwilson wilfwilson added resolved-pending-release A label for issues that have been resolved and that can be closed when a new version is released. and removed resolved-pending-merge A label for issues that are resolved in a PR that is not yet merged. labels Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A label for issues that are bugs resolved-pending-release A label for issues that have been resolved and that can be closed when a new version is released.
Projects
None yet
Development

No branches or pull requests

2 participants