Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Kaz Kylheku <221-501-9011@kylheku.com> Newsgroups: comp.compilers Subject: Re: Alternative C compilers on x86_64 Linux? Date: Tue, 6 Sep 2016 02:15:52 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 64 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <16-09-009@comp.compilers> References: <16-09-001@comp.compilers> <16-09-005@comp.compilers> Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="9640"; mail-complaints-to="abuse@iecc.com" Keywords: C Posted-Date: 06 Sep 2016 14:49:31 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1748 On 2016-09-05, BartC wrote: > On 02/09/2016 04:01, Aharon Robbins wrote: > >> TinyCC is blindingly fast, and can compile gawk, but is broken in that >> it won't diagnose duplicate case statements inside switch. The developers >> don't consider this a problem. So I refuse to use it. >> >> In short, I'm looking for a faster compiler that actually works. > > I'm quite impressed with Tiny CC. I'd considered it a toy compiler that > could only compile a small subset of the language until I actually tried it. > > And yes, on my Win64 version, it does seem to ignore duplicate 'case' > labels. > > But TCC does have problem with compiling switch statements; although the > code it generates isn't that great anyway, that for switches is slower. > > I suspect it just compiles switch as an if-else chain. Which might > explain why duplicate case labels are ignored if that conversion is done > at at early stage. > > (Because a duplicate condition in an if-else chain is fine. For a > jump-table of course, a duplicate label is ambiguous so can't be allowed.) A duplicate condition in an if-else chain is unreachable code, which is probably a bug. if (foo) { ... } else if (foo) { /* unreachable */ } else if (bar) { ... } Duplicate cases are a constraint violation in ISO C, requiring a diagnostic. A duplicate label can also be just as "fine". Look, you can build a jump table, and then just fill it without caring about duplicates: case 42: ... case 42: No problem: just write to jumptable[42] twice, letting it the most recently established address overrule the previous one. Duplicate case label code can still be reachable, making the bugs potentially more interesting: case 42: // suppose this is used ... break; case 19: ... /* fallthrough */ case 42: // this isn't used, but fallthrough makes it reachable -- TXR Programming Lanuage: http://nongnu.org/txr Music DIY Mailing List: http://www.kylheku.com/diy ADA MP-1 Mailing List: http://www.kylheku.com/mp1