This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: FW: Complier not giving warning/error in this scenario.. Please help..
- From: Ian Lance Taylor <ian at airs dot com>
- To: "Soujanya Gundlapalli" <souj at packetware dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 29 Sep 2005 10:47:30 -0700
- Subject: Re: FW: Complier not giving warning/error in this scenario.. Please help..
- References: <003401c5c4a2$ac8153f0$a114a8c0@packetsouj>
"Soujanya Gundlapalli" <souj@packetware.com> writes:
> I am trying to compile the file with the following code.
>
> Originally it was:
> if ((erc = pk_val(pline, pkt, mp, PKT_CLEAR, PK_LOCAL))
> By accident I saved the file with the following code.
> if ((erc = (pline, pkt, mp, PKT_CLEAR, PK_LOCAL))
>
> By accident pk_val_call got deleted and when I complied the above code
> using the options
> cc -c -g, it got compiled successfully. I tried removing -g also. Even
> then it gave success. Is this a problem with the compiler? Is there a
> fix for this that I can use.
You are using the comma operator. In C or C++ the value of "(a, b)"
is to evaluate "a", and then to return the value of "b". This is only
generally useful if "a" has a side-effect, like a function call. But
it is always legal. So the above code is correct.
If you compile with -Wall, you should get a warning along the lines of
"left-hand operand of comma expression has no effect".
Ian