test/sparse_array_test.c:89: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `ossl_sa_char_set`.
Showing all 14 steps of the trace


test/sparse_array_test.c:89:14: Call
87.           goto err;
88.       for (i = 0; i < OSSL_NELEM(cases); i++)
89.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))
                   ^
90.                   || !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))
91.               goto err;

test/sparse_array_test.c:28:1: Parameter `sa->nelem`
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

test/sparse_array_test.c:28:1: Call
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:183:1: Parameter `sa->nelem`
    181.   }
    182.   
    183. > int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)
    184.   {
    185.       int i, level = 1;

test/sparse_array_test.c:89:14: Call
87.           goto err;
88.       for (i = 0; i < OSSL_NELEM(cases); i++)
89.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))
                   ^
90.                   || !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))
91.               goto err;

test/sparse_array_test.c:28:1: Parameter `sa->nelem`
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

test/sparse_array_test.c:28:1: Call
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:183:1: Parameter `sa->nelem`
    181.   }
    182.   
    183. > int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)
    184.   {
    185.       int i, level = 1;

test/sparse_array_test.c:89:14: Call
87.           goto err;
88.       for (i = 0; i < OSSL_NELEM(cases); i++)
89.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))
                   ^
90.                   || !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))
91.               goto err;

test/sparse_array_test.c:28:1: Parameter `sa->nelem`
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

test/sparse_array_test.c:28:1: Call
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:183:1: <LHS trace>
181.   }
182.   
183. > int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)
184.   {
185.       int i, level = 1;

crypto/sparse_array.c:183:1: Parameter `sa->nelem`
    181.   }
    182.   
    183. > int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)
    184.   {
    185.       int i, level = 1;

crypto/sparse_array.c:215:9: Binary operation: ([0, +oo] - 1):unsigned64 by call to `ossl_sa_char_set` 
    213.       p += posn & SA_BLOCK_MASK;
    214.       if (val == NULL && *p != NULL)
    215.           sa->nelem--;
                   ^
    216.       else if (val != NULL && *p == NULL)
    217.           sa->nelem++;

int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)
{
    int i, level = 1;
    ossl_uintmax_t n = posn;
    void **p;
    if (sa == NULL)
        return 0;
    for (level = 1; level < SA_BLOCK_MAX_LEVELS; level++)
        if ((n >>= OPENSSL_SA_BLOCK_BITS) == 0)
            break;
    for (;sa->levels < level; sa->levels++) {
        p = alloc_node();
        if (p == NULL)
            return 0;
        p[0] = sa->nodes;
        sa->nodes = p;
    }
    if (sa->top < posn)
        sa->top = posn;
    p = sa->nodes;
    for (level = sa->levels - 1; level > 0; level--) {
        i = (posn >> (OPENSSL_SA_BLOCK_BITS * level)) & SA_BLOCK_MASK;
        if (p[i] == NULL && (p[i] = alloc_node()) == NULL)
            return 0;
        p = p[i];
    }
    p += posn & SA_BLOCK_MASK;
    if (val == NULL && *p != NULL)
        sa->nelem--;
    else if (val != NULL && *p == NULL)
        sa->nelem++;
    *p = val;
    return 1;
}
['static int test_sparse_array_num(void)\n{\n    static const struct {\n        size_t num;\n        ossl_uintmax_t n;\n        char *v;\n    } cases[] = {\n        { 1, 22, "a" }, { 2, 1021, "b" }, { 3, 3, "c" }, { 2, 22, NULL },\n        { 2, 3, "d" }, { 3, 22, "e" }, { 3, 666, NULL }, { 4, 666, "f" },\n        { 3, 3, NULL }, { 2, 22, NULL }, { 1, 666, NULL }, { 2, 64000, "g" },\n        { 1, 1021, NULL }, { 0, 64000, NULL }, { 1, 23, "h" }, { 0, 23, NULL }\n    };\n    SPARSE_ARRAY_OF(char) *sa = NULL;\n    size_t i;\n    int res = 0;\n    if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)\n            || !TEST_ptr(sa = ossl_sa_char_new())\n            || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))\n        goto err;\n    for (i = 0; i < OSSL_NELEM(cases); i++)\n        if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))\n                || !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))\n            goto err;\n    res = 1;\nerr:\n    ossl_sa_char_free(sa);\n    return res;\n}', 'DEFINE_SPARSE_ARRAY_OF(char)', 'int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)\n{\n    int i, level = 1;\n    ossl_uintmax_t n = posn;\n    void **p;\n    if (sa == NULL)\n        return 0;\n    for (level = 1; level < SA_BLOCK_MAX_LEVELS; level++)\n        if ((n >>= OPENSSL_SA_BLOCK_BITS) == 0)\n            break;\n    for (;sa->levels < level; sa->levels++) {\n        p = alloc_node();\n        if (p == NULL)\n            return 0;\n        p[0] = sa->nodes;\n        sa->nodes = p;\n    }\n    if (sa->top < posn)\n        sa->top = posn;\n    p = sa->nodes;\n    for (level = sa->levels - 1; level > 0; level--) {\n        i = (posn >> (OPENSSL_SA_BLOCK_BITS * level)) & SA_BLOCK_MASK;\n        if (p[i] == NULL && (p[i] = alloc_node()) == NULL)\n            return 0;\n        p = p[i];\n    }\n    p += posn & SA_BLOCK_MASK;\n    if (val == NULL && *p != NULL)\n        sa->nelem--;\n    else if (val != NULL && *p == NULL)\n        sa->nelem++;\n    *p = val;\n    return 1;\n}']