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


test/sparse_array_test.c:51:14: Call
49.   
50.       for (i = 0; i < OSSL_NELEM(cases); i++) {
51.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))) {
                   ^
52.               TEST_note("iteration %zu", i + 1);
53.               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:51:14: Call
49.   
50.       for (i = 0; i < OSSL_NELEM(cases); i++) {
51.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))) {
                   ^
52.               TEST_note("iteration %zu", i + 1);
53.               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(void)\n{\n    static const struct {\n        ossl_uintmax_t n;\n        char *v;\n    } cases[] = {\n        { 22, "a" }, { 0, "z" }, { 1, "b" }, { 290, "c" },\n        { INT_MAX, "m" }, { 6666666, "d" }, { (ossl_uintmax_t)-1, "H" },\n        { 99, "e" }\n    };\n    SPARSE_ARRAY_OF(char) *sa;\n    size_t i, j;\n    int res = 0;\n    if (!TEST_ptr(sa = ossl_sa_char_new())\n            || !TEST_ptr_null(ossl_sa_char_get(sa, 3))\n            || !TEST_ptr_null(ossl_sa_char_get(sa, 0))\n            || !TEST_ptr_null(ossl_sa_char_get(sa, UINT_MAX)))\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_note("iteration %zu", i + 1);\n            goto err;\n        }\n        for (j = 0; j <= i; j++)\n            if (!TEST_str_eq(ossl_sa_char_get(sa, cases[j].n), cases[j].v)) {\n                TEST_note("iteration %zu / %zu", i + 1, j + 1);\n                goto err;\n            }\n    }\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}']