Re: dead code or otherwise, was Alternative C compilers on x86_64 Linux?

George Neuner <gneuner2@comcast.net>
Thu, 08 Sep 2016 11:58:41 -0400

          From comp.compilers

Related articles
Alternative C compilers on x86_64 Linux? arnold@skeeve.com (2016-09-02)
Re: Alternative C compilers on x86_64 Linux? bc@freeuk.com (BartC) (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? bc@freeuk.com (BartC) (2016-09-06)
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)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu gneuner2@comcast.net (George Neuner) (2016-09-09)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-09)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu gneuner2@comcast.net (George Neuner) (2016-09-09)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-09)
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Thu, 08 Sep 2016 11:58:41 -0400
Organization: A noiseless patient Spider
References: 16-09-001 16-09-005 16-09-009 16-09-012
Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="92304"; mail-complaints-to="abuse@iecc.com"
Keywords: C, optimize
Posted-Date: 08 Sep 2016 16:48:10 EDT

On Tue, 6 Sep 2016 21:35:30 +0100, BartC <bc@freeuk.com> wrote:


>On 06/09/2016 03:15, Kaz Kylheku wrote:
>
>> 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) {
>> ...
>> }
>
>It's not necessarily unreachable. For example:
>
> if (foo()) { ...}
> elsif if (foo()) { ... }
>
>foo() could return false the first time and true the second time.


In such cases foo doesn't need to be function - it only needs to be a
[moral equivalent of a C] volatile to exhibit strange behavior.


Writing an IF chain with multiple identical tests probably should be a
style warning in and of itself.




>In general detecting duplication conditions for if-else can involve
>comparing expressions of arbitrary complexity, and it can be harder to
>determine if they will always yield the same value.


Yes. It's infeasible in most circumstances.


George


Post a followup to this message

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