lkml.org 
[lkml]   [2000]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Patch to remove undefined C code
Also sprach Mark Montague:
}
} dn[i], i++ evaluates to i, but str[i] = dn[i], i++ sets str[i] to
} dn[i] first, then increments i returning its previous value, which is
} discarded. Which was probably specified this way so
}
} for(i=1,j=2; something; something else)
}
} works as expected, rather than setting i and j to 2, and discarding
} the 1.
}
Um...it sets i to 1 and j to 2.

} Just to encourage empiricism, I usually check stuff like that with
}
} % cat > foo.c
} main(){
} int i;
} i = 1 , 2;
} printf("%d\n",i);
} }
} % gcc foo.c
} % ./a.out
} 1
}
} or similar if I'm confused.
}
This isn't a good test of what's proper according to the standard. If you
are testing some undefined part of the standard, a compile may get it
"right" in one version but is perfectly within its rights to do something
else in the next version. The only way to solve these things is to look
at what the standard says and follow it. All else is hopes and wishes.
The above code is specified as working in the standard (evaluating the
assign and then evaluating the 2).

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

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