test/sparse_array_test.c:163: 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:163:14: Call
161.       doall_data.sa = NULL;
162.       for (i = 0; i <  OSSL_NELEM(cases); i++)
163.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))) {
                    ^
164.               TEST_note("failed at iteration %zu", i + 1);
165.               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:181:1: Parameter `sa->nelem`
    179.   }
    180.   
    181. > int OPENSSL_SA_set(OPENSSL_SA *sa, size_t posn, void *val)
    182.   {
    183.       int i, level = 1;

test/sparse_array_test.c:163:14: Call
161.       doall_data.sa = NULL;
162.       for (i = 0; i <  OSSL_NELEM(cases); i++)
163.           if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))) {
                    ^
164.               TEST_note("failed at iteration %zu", i + 1);
165.               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:181:1: <LHS trace>
179.   }
180.   
181. > int OPENSSL_SA_set(OPENSSL_SA *sa, size_t posn, void *val)
182.   {
183.       int i, level = 1;

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

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

int OPENSSL_SA_set(OPENSSL_SA *sa, size_t posn, void *val)
{
    int i, level = 1;
    size_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_doall(void)\n{\n    static const struct index_cases_st cases[] = {\n        { 22, "A", 1 }, { 1021, "b", 0 }, { 3, "c", 0 }, { INT_MAX, "d", 1 },\n        { (size_t)-1, "H", 0 }, { (size_t)-2, "i", 1 }, { 666666666, "s", 1 },\n        { 1234567890, "t", 0 },\n    };\n    struct doall_st doall_data;\n    size_t i;\n    SPARSE_ARRAY_OF(char) *sa = NULL;\n    int res = 0;\n    if (!TEST_ptr(sa = ossl_sa_char_new()))\n        goto err;\n    doall_data.num_cases = OSSL_NELEM(cases);\n    doall_data.cases = cases;\n    doall_data.all = 1;\n    doall_data.sa = NULL;\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("failed at iteration %zu", i + 1);\n            goto err;\n    }\n    ossl_sa_char_doall_arg(sa, &leaf_check_all, &doall_data);\n    if (doall_data.res == 0) {\n        TEST_info("while checking all elements");\n        goto err;\n    }\n    doall_data.all = 0;\n    doall_data.sa = sa;\n    ossl_sa_char_doall_arg(sa, &leaf_delete, &doall_data);\n    if (doall_data.res == 0) {\n        TEST_info("while deleting selected elements");\n        goto err;\n    }\n    ossl_sa_char_doall_arg(sa, &leaf_check_all, &doall_data);\n    if (doall_data.res == 0) {\n        TEST_info("while checking for deleted elements");\n        goto err;\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, size_t posn, void *val)\n{\n    int i, level = 1;\n    size_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}']