J
jimjim
Is the footnote 70 of 6.5.2 that talks about undefined behavior?
oups 6.5,2
oups 6.5,2
jimjim said:70) This paragraph renders undefined statement expressions such as
i = ++i + 1;
a[i++] = i;
why does the last expression invoke undefined behavior? The value of i is
changed once (I would have guessed that the initial value of i would have
been stored in a,
and then the i++ would have been performed before
proceeding to the next statement in the code.
P.S: posters should stop making assumptions that newbies can comprenhend
everything they are reading in the FAQ!
jimjim said:In order to make sure that I understand what you are saying, is the sentence
below equivalent with yours?
If between sequence points an object's value is to be modified , its value
should only be read once.
This now makes sense to me. thxtwo sequence points, then it can only be written once, and read
accesses must be done in order to compute the new value, and for no
other porpouse.
[snip]jimjim said:Hi there..thx for the reply
jimjim said:Moreover, http://www.eskimo.com/~scs/C-faq/q11.33.html refers to
implementation-defined.
1. Is implementation-defined stated in particular sections of the Standard?
2. Is there a possibility for an implementation to choose some behavior for
a Standard-specified Undefined behaviour and document it?
jimjim said:Moreover, http://www.eskimo.com/~scs/C-faq/q11.33.html refers to
implementation-defined.
1. Is implementation-defined stated in particular sections of the Standard?
2. Is there a possibility for an implementation to choose some behavior for
a Standard-specified Undefined behaviour and document it?
jimjim said:Hello,
#include <stdio.h>
int main(int argc, char *argv[])
{
int x = 1;
printf("%d %d %d\n", ++x, x, x++);
return 0;
}
Why does the above code when compiled with all warnings it issues: "
warning: operation on `x' may be undefined"?
Why when run the output is: "3 2 1"?
Mark said:jimjim said:Hello,
#include <stdio.h>
int main(int argc, char *argv[])
{
int x = 1;
printf("%d %d %d\n", ++x, x, x++);
return 0;
}
Why does the above code when compiled with all warnings it issues: "
warning: operation on `x' may be undefined"?
Why when run the output is: "3 2 1"?
Everyone here is quick to post that the code invokes undefined behavior,
but doesn't the following excerpt from the standard explicitly allow it?
7.19.6 Formatted input/output functions
1) The formatted input/output functions shall behave as if there is a
sequence point after
the actions associated with each specifier.
7.19.6.1 The fprintf function
Mark said:jimjim said:Hello,
#include <stdio.h>
int main(int argc, char *argv[])
{
int x = 1;
printf("%d %d %d\n", ++x, x, x++);
return 0;
}
Why does the above code when compiled with all warnings it issues: "
warning: operation on `x' may be undefined"?
Why when run the output is: "3 2 1"?
Everyone here is quick to post that the code invokes undefined behavior,
but doesn't the following excerpt from the standard explicitly allow it?
7.19.6 Formatted input/output functions
1) The formatted input/output functions shall behave as if there is a
sequence point after
the actions associated with each specifier.
7.19.6.1 The fprintf function
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.