October 03, 2005 incorrect "switch statement is not reachable" for large switch statements without a default case | ||||
---|---|---|---|---|
| ||||
Attachments: | http://dstress.kuehne.cn/benchmark/known_gcc_problems/gcc_7344.d - ----------------------------------------------------- int f(){ printf("F\n"); return 0; } int main(char[][] args) { if(args.length<1){ c: return 0; } switch (args.length) { // **line 20** case 1: f(); goto c; case 2: f(); goto c; case 3: f(); goto c; [...] case 9999: f(); goto c; case 10000: f(); goto c; } } - ----------------------------------------------------- >dmd -w gcc_7344.d warning - gcc_7344.d(20): switch statement has no default warning - gcc_7344.d(20): statement is not reachable warning - gcc_7344.d(16): function dstress.benchmark.gcc_7344.main no return at end of function Adding a default case removes the "not reacheable" warning. Thomas |
Copyright © 1999-2021 by the D Language Foundation