stdcxx-dev  

21.strings.cpp bug

Farid Zaripov
Mon, 03 Jul 2006 08:56:37 -0700

I found the following code in 21.strings.cpp line 1504:

                if (StringIds::None == iter_types [l]) {
                    // skip a non-sensical template specialization
>                   break;
                }

Here the "break" clause should be replaced with "continue".

Suppose that in the StringTest array some template method is situated before any non-template method(s). The current version will skip these non-template methods exercising because of this "break".

Example:

21.string.cons.cpp

    static const StringTest
    tests [] = {

#undef TEST
#define TEST(sig) {                                             \
        Cons (sig), sig ## _test_cases,                         \
        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
    }

          [...]

        TEST (range),

#undef TEST
#define TEST(sig) {                             \
        OpSet (sig), sig ## _op_set_test_cases, \
          sizeof sig ## _op_set_test_cases      \
        / sizeof *sig ## _op_set_test_cases     \
    }

        TEST (cptr),
        TEST (cstr),
        TEST (val)

    };


Test results (OpSet(cptr), OpSet(cstr), OpSet(val) were not tested):
# +-----------------------+--------+--------+--------+
# | DIAGNOSTIC            | ACTIVE |  TOTAL |INACTIVE|
# +-----------------------+--------+--------+--------+
# | (S1) INFO             |    171 |    171 |     0% |
# | (S2) NOTE             |      0 |    170 |   100% |
# | (S7) ASSERTION        |      0 |  17910 |   100% |
# +-----------------------+--------+--------+--------+


If "break" is replaced to "continue" (all overloads were tested):
# +-----------------------+--------+--------+--------+
# | DIAGNOSTIC            | ACTIVE |  TOTAL |INACTIVE|
# +-----------------------+--------+--------+--------+
# | (S1) INFO             |    201 |    201 |     0% |
# | (S2) NOTE             |      0 |    200 |   100% |
# | (S7) ASSERTION        |      0 |  21843 |   100% |
# +-----------------------+--------+--------+--------+


Farid.