lkml.org 
[lkml]   [1999]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [OFFTOPIC] Re: A bit off-topic ... (fwd)
On Thu, Apr 01, 1999 at 08:42:01AM +0800, David Luyer wrote:
> Try this one -
>
> main() {
> int x=0, y=0, z = 0;
>
> x ? y : z = 1;
>
> printf("%d %d %d\n", x, y, z);
> }
>
> Compiles fine. Output: 0 0 1.
> Now set x=1 and find output: 1 1 0.
> Isn't that sick :-) gcc 2.7.2.3.

what's sick about it? it's a documented gcc extension.

>
> Based on that, a really good compiler could give your above statement as
>
> x = (x=1) = 2

this is illegal. First, (x=1) is not an lvalue, secondly even if it were,
the assignment would be undefined.

>
> and then come out with x = 2.

or mke2fs /dev/{h,s}da just to teach you a lesson :)

-- arvind

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.047 / U:1.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site