Re: Compiler error or my mistake



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.
.



Relevant Pages

  • Re: [C++] const vs. static
    ... > 'str' is a static pointer to a char; ... > the address of the first element of the string literal. ... At file scope it means the identifier `str' is only visible ...
    (alt.comp.lang.learn.c-cpp)
  • Re: buildworld failures on STABLE
    ... compiler error: Segmentation fault: 11 ... The compiler dying with signal 11 is a typical memory problem. ... kernel places strict limit to amount of memory that user-level application ...
    (freebsd-stable)
  • Re: inheritance, types, operator overload, head ache
    ... Can some one *please* splain me why strworks but not print obj, ... class Byte(str): # Implement Bytes as str for easy adding and joining ... #ensure input is valid struct ...
    (comp.lang.python)
  • Re: Whither VMS?
    ... (snip regarding C str... ... implemented, such as strcat and memcpy, but they reserved them all to ...
    (comp.os.vms)
  • Re: Whither VMS?
    ... (snip regarding C str... ... implemented, such as strcat and memcpy, but they reserved them all to ...
    (comp.os.vms)