Re: Alternative C compilers on x86_64 Linux?

Kaz Kylheku <221-501-9011@kylheku.com>
Tue, 6 Sep 2016 02:15:52 +0000 (UTC)

          From comp.compilers

Related articles
[2 earlier articles]
Re: Alternative C compilers on x86_64 Linux? nemo@invalid.invalid (Nemo) (2016-09-04)
Re: Alternative C compilers on x86_64 Linux? 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-04)
Re: Alternative C compilers on x86_64 Linux? bc@freeuk.com (BartC) (2016-09-05)
Re: Alternative C compilers on x86_64 Linux? fw@deneb.enyo.de (Florian Weimer) (2016-09-05)
Re: Alternative C compilers on x86_64 Linux? alexfrunews@gmail.com (2016-09-05)
Re: Alternative C compilers on x86_64 Linux? alexfrunews@gmail.com (2016-09-05)
Re: Alternative C compilers on x86_64 Linux? 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-06)
Re: Alternative C compilers on x86_64 Linux? 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-06)
Re: Alternative C compilers on x86_64 Linux? bc@freeuk.com (BartC) (2016-09-06)
Re: duplicate cases, was Alternative C compilers on x86_64 Linux? anw@cuboid.co.uk (Andy Walker) (2016-09-07)
Re: Alternative C compilers on x86_64 Linux? rockbrentwood@gmail.com (2016-09-07)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu gneuner2@comcast.net (George Neuner) (2016-09-08)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-08)
[25 later articles]
| List of all articles for this month |

From: Kaz Kylheku <221-501-9011@kylheku.com>
Newsgroups: comp.compilers
Date: Tue, 6 Sep 2016 02:15:52 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 16-09-001 16-09-005
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

On 2016-09-05, BartC <bc@freeuk.com> 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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.