i...@adari.net writes:
> 1. It is wise then to insure that the final value of an expression is
> ascertained upfront before it is being used in a function call as an
> argument. I suppose this is applicable in all cases of expressions
> and not limited to pre and post increments, although, pre an
1. It is wise then to insure that the final value of an expression is
ascertained upfront before it is being used in a function call as an
argument. I suppose this is applicable in all cases of expressions
and not limited to pre and post increments, although, pre and post
is where there is likely
Andreas Schwab wrote:
> Zachary Turner writes:
>
>> So if a=5 before a function call, then foo(++a, ++a), might invoke
>> foo(6, 6), foo(6, 7), or foo(7, 6).
>
> Or even foo(42, 666).
Or demons might fly out of your nose.
Andrew.
Zachary Turner writes:
> So if a=5 before a function call, then foo(++a, ++a), might invoke
> foo(6, 6), foo(6, 7), or foo(7, 6).
Or even foo(42, 666).
Andreas.
--
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for somet
As the C specification document specifies in section 6.5.2.2 point no 10:
The order of evaluation of the function designator, the actual arguments, and
subexpressions within the actual arguments is unspecified, but there
is a sequence point
before the actual call.
Therefore if in any function cal
2009/7/20 :
> Hello Andrew,
>
> Thanks for your suggestion, but no difference in output.
>
> Question: Did you expect different output too?
Not really. Although it may occur with different compiler versions or flags.
See http://en.wikipedia.org/wiki/Sequence_point and
http://c-faq.com/expr/seqpo
On Mon, Jul 20, 2009 at 10:30 AM, wrote:
> Hello,
>
> Here is a program with output in gcc (4.3.2) on pre and post increments:
>
> //code begin
> #include
>
> main () {
> int a;
> a=1; printf ("1. %d %d\n", ++a, a);
On Mon, Jul 20, 2009 at 8:48 AM, wrote:
> Hello Andrew,
>
> Thanks for your suggestion, but no difference in output.
>
> Question: Did you expect different output too?
Oh the warnings are telling you, your code is undefined.
-- Pinski
PS gcc-h...@gcc.gnu.org is a better mailing list for these t
Hello Andrew,
Thanks for your suggestion, but no difference in output.
Question: Did you expect different output too?
Thanks
Quo ting Andrew Pinski :
> On Mon, Jul 20, 2009 at 8:30 AM, wrote:
> > Hello,
> >
> > Here is a program with output in gcc (4.3.2) on pre and post increments:
>
> Try
On Mon, Jul 20, 2009 at 8:30 AM, wrote:
> Hello,
>
> Here is a program with output in gcc (4.3.2) on pre and post increments:
Try using -Wsequence-point. With that option GCC produces:
t.c:6: warning: operation on 'a' may be undefined
(and many warnings of the same wording for every line afterwa
Hello,
Here is a program with output in gcc (4.3.2) on pre and post increments:
//code begin
#include
main () {
int a;
a=1; printf ("1. %d %d\n", ++a, a); // 1. 2 2
a=1; printf ("2. %d %d\n", a, a++)
11 matches
Mail list logo