Skip to content

Always true comparison in lifting-gb.c #325

@jamesjer

Description

@jamesjer

When building msolve version 0.9.5, gcc warns:

In file included from msolve.c:25,
                 from libmsolve.c:35:
lifting-gb.c: In function 'verif_lifted_basis':
lifting-gb.c:1102:36: warning: the comparison will always evaluate as 'true' for the pointer operand in 'modgbs->modpolys + (sizetype)((long unsigned int)k * 48)' must not be NULL [-Waddress]
 1102 |             if(modgbs->modpolys[k] != NULL){
      |                                    ^~

The variable modgbs has type gb_modpoly_t, so the type of modgbs->modpolys is:

  modpolys_t *modpolys; /* array of polynomials modulo primes */

where the modpolys_t type is:

typedef modpolys_struct modpolys_t[1];

That is, modgbs->modpolys is a pointer to an array, where each element is an array of modpolys_struct of length 1. The code that the compiler warns about seems to have been written with the belief that modgbs->modpolys is an array of pointers to modpolys_struct objects. It isn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions