I was browsing some code in the linux kernel and I came across the statements like case \'0\' ... \'9\':
To try this out I created the test program belo
This is a GCC extension to C, mentioned in this answer to what is basically a duplicate question, and confirmed in the GCC documentation.
That's an extension. Compiling your program with -pedantic
gives:
example.cpp: In function ‘int main()’:
example.cpp:9: error: range expressions in switch statements are non-standard
example.cpp:12: error: range expressions in switch statements are non-standard
clang
gives even better warnings:
example.cpp:9:12: warning: use of GNU case range extension [-Wgnu]
case 0 ... 10:
^
example.cpp:12:13: warning: use of GNU case range extension [-Wgnu]
case 11 ... 100:
^
That is the case range extension of the GNU C compiler, it is not standard C or C++.