This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: A simple question on expression
- To: Jie Zhang <jzhang916 at sina dot com>
- Subject: Re: A simple question on expression
- From: Bohdan Vlasyuk <bohdan at kivc dot vstu dot vinnica dot ua>
- Date: Fri, 31 Aug 2001 11:13:00 +0300
- Cc: gcc at gcc dot gnu dot org
- References: <3B8F3B41.40900@sina.com>
On Fri, Aug 31, 2001 at 03:22:41PM +0800, Jie Zhang wrote:
> I want to ask a simple question on expression.
[...]
> a = (a<4)?0:a++; /* 1 */
[...]
> Who can tell me why the two printfs print out different results?
that is obvious!
second expression ([1]) is undefined -- it expands to:
if (a<4)
a=0;
else
a=a++; /* 2 */
[2] is undefined -- i.e a can take whatever possible value after it.
Please, read K&R before asking such questions.
--
They finally got King Midas, I hear. Gild by association.