[-Wswapped-range]ΒΆ

This warning is very simple. It warns you in cases when character class contains a range which lower bound is greater than upper bound. For some strange reason re2c never considered it an error: it simply swaps range bounds and goes on.

1
2
3
4
/*!re2c
    *     { return "*"; }
    [a-Z] { return "is it what you want?"; }
*/

Given this code, `re2c -i -Wswapped-range` generates the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Generated by re2c 0.14.1.dev on Tue Nov 10 22:07:31 2015*/

{
        YYCTYPE yych;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
        switch (yych) {
        case 'Z':
        case '[':
        case '\\':
        case ']':
        case '^':
        case '_':
        case '`':
        case 'a':       goto yy4;
        default:        goto yy2;
        }
yy2:
        ++YYCURSOR;
        { return "*"; }
yy4:
        ++YYCURSOR;
        { return "is it what you want?"; }
}

And reports a warning:

re2c: warning: line 3: range lower bound (0x61) is greater than upper bound (0x5A), swapping [-Wswapped-range]

Use [-Werror-swapped-range] to make it an error.