Re: Compiler error or my mistake
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Mon, 12 Oct 2009 12:04:15 +0100
Seebs <usenet-nospam@xxxxxxxxx> writes:
On 2009-10-11, jwes <j.wesley.cleveland@xxxxxxxxx> wrote:
The c standard says that that compound if statements do not evaluate
the second part if the first part is false, e.g. "if (str && *str)"
does not give an error if str is null. I wanted both parts evaluated,
so I put extra parentheses "if ((a && b))", and one popular compiler
still did not evaluate b if a is false. Is this a compiler error?
No. Why on earth would you think the parenthesis would change something?
The OP explains why in the first sentence. If one believes that the
if's initial "(" is followed by some clauses that are separated by &&
then it makes sense that grouping two of them into one might alter
the execution.
Of course, you and I both know that it does not make sense for C to be
designed that way, but it takes some time to get there.
<snip>
--
Ben.
.
- References:
- Compiler error or my mistake
- From: jwes
- Re: Compiler error or my mistake
- From: Seebs
- Compiler error or my mistake
- Prev by Date: Re: Function pointers: performance penalty?
- Next by Date: Re: Function pointers: performance penalty?
- Previous by thread: Re: Compiler error or my mistake
- Next by thread: subroutine stack and C machine model
- Index(es):
Relevant Pages
|