473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Is i = i++; bad style?

i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

Jul 6 '07 #1
92 2881
On Jul 6, 11:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
As a part of a compound expression, i = i++ (an expression, no
semocolon followed) may be undefined value, right?

Jul 6 '07 #2
On Jul 5, 11:28 pm, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
On Jul 6, 11:25 am, "lovecreatesbea...@gmail.com"

<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

As a part of a compound expression, i = i++ (an expression, no
semocolon followed) may be undefined value, right?
It is undefined both as part of a larger expression and as a
standalone expression. 9899:1999 §6.5p2 reads:

"Between the previous and next sequence point an object shall have its
stored value
modified at most once by the evaluation of an expression. Furthermore,
the prior value
shall be read only to determine the value to be stored."

Assignment does not introduce a sequence point so i is modified twice
without an intervening sequence point, once by the ++ operator and
once by the assignment. Violation of a "shall" outside of a
constraint (as is the case here) causes undefined behavior. See also
<http://www.c-faq.com/question 3.3.

Robert Gamble

Jul 6 '07 #3
On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.

Jul 6 '07 #4
"lovecreatesbea...@gmail.com" wrote:
>
i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
No. The result is undefined. Incrementing by one is a
possibility. Just use "i++;" alone for an accurate increment.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #5
On Jul 6, 11:57 am, Francine.Ne...@googlemail.com wrote:
On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"

<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.
Don't you think the following program prints 11 on any or your system?
Isn't it portable?

int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;
}

Jul 6 '07 #6
"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrites:
i = i++;
<http://www.c-faq.com/>, question 3.3.

Sheesh.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '07 #7

lovecreatesbea...@gmail.com wrote:
i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
Yes you are right, but diffrent compiler may behave in diffrent way.
in short it is compiler dependent.

~Ranjeet

Jul 6 '07 #8
lovecreatesbea...@gmail.com wrote:
>
Don't you think the following program prints 11 on any or your system?
Isn't it portable?

int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;
}
No, it's not. It invokes undefined behaviour for reasons already stated
elsewhere on this thread (no intervening sequence point between two
modifications of a same variable). It could print anything, not anything
at all, or even do something completely unrelated to printing.

--
Denis Kasak

Jul 6 '07 #9
ra***********@gmail.com wrote, On 06/07/07 06:45:
lovecreatesbea...@gmail.com wrote:
>i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

Yes you are right, but diffrent compiler may behave in diffrent way.
in short it is compiler dependent.
Or a different version of the same compiler, or the same compiler with
different options, or the same compiler with the same options but
something different in the source code which is apparently completely
unrelated (yes, I have seen apparently unrelated code have effects on
the code of interest, that's the fun thing with optimisers). In short,
the OP was correct ONLY for the specific run that the OP did where that
was the observed result, in general (even with the same compiler etc)
the OP is WRONG, because the only thing that can be said with certainty
is that it invokes undefined behaviour.

By the way, since the OP has been around for a long time off and on yet
is asking the question I think it is either a troll or fundamentally
incapable of learning to program in C. The meaning of undefined
behaviour was even explained to the OP back in 2005
http://groups.google.co.uk/group/com...4158409a166ce4
--
Flash Gordon
Jul 6 '07 #10
On Jul 6, 1:34 pm, Keith Thompson <k...@mib.orgwrote:
"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrites:
i = i++;

<http://www.c-faq.com/>, question 3.3.

Sheesh.

--
Keith Thompson (The_Other_Keith) k...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
I had this question when I was reading the c-faq. As for

i = i++;

I ever thought it works in following two ways.

1.
i = i /*no sequencing point followed immediately*/
i++
; /*sequencing point */

So, result: i = i + 1;

2.
i++ /*no sequencing point followed immediately,
but will the increasing effect be lost?*/
i = i /*i was assigned to itself*/
; /*sequencing point */

So, result: i = i;

And the result isn't certain.

Do I think it correctly?

Jul 6 '07 #11
On Jul 6, 3:44 pm, Flash Gordon <s...@flash-gordon.me.ukwrote:
ranjeet.gu...@gmail.com wrote, On 06/07/07 06:45:
lovecreatesbea...@gmail.com wrote:
By the way, since the OP has been around for a long time off and on yet
is asking the question I think it is either a troll or fundamentally
incapable of learning to program in C. The meaning of undefined
behaviour was even explained to the OP back in 2005http://groups.google.co.uk/group/comp.lang.c/browse_frm/thread/2b0e0f...
Why are you so impolite and unkind to people?

Jul 6 '07 #12
On Jul 5, 10:32 pm, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
On Jul 6, 11:57 am, Francine.Ne...@googlemail.com wrote:
On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.

Don't you think the following program prints 11 on any or your system?
No. Since its behaviour is undefined, I don't know if it will compile
at all, or if it will print anything at all, let alone if it will
print 11. Since its behaviour is undefined, I don't care what it does,
and don't care to waste my time finding out.
Isn't it portable?
No, as you've been repeatedly told.
int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;
}
Jul 6 '07 #13
Robert Gamble said:
On Jul 5, 11:28 pm, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
>On Jul 6, 11:25 am, "lovecreatesbea...@gmail.com"

<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

As a part of a compound expression, i = i++ (an expression, no
semocolon followed) may be undefined value, right?

It is undefined both as part of a larger expression and as a
standalone expression.
Please don't feed the trolls. This guy has been around clc for quite
long enough (like, years) that he ought to know by now where to find
the FAQ, and that he must have learned the answer to his question a
dozen times or more.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 6 '07 #14
On Jul 6, 6:15 pm, Richard Heathfield <r...@see.sig.invalidwrote:
Robert Gamble said:


On Jul 5, 11:28 pm, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
On Jul 6, 11:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
As a part of a compound expression, i = i++ (an expression, no
semocolon followed) may be undefined value, right?
It is undefined both as part of a larger expression and as a
standalone expression.

Please don't feed the trolls. This guy has been around clc for quite
long enough (like, years) that he ought to know by now where to find
the FAQ, and that he must have learned the answer to his question a
dozen times or more.
Man, why do you always keep angry? Can you be reasonable? Are you the
god on the net?

Jul 6 '07 #15
Fr************@googlemail.com wrote:
On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".

But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.
The OP is either a more subtle and consistent troll than usual, or
entirely bereft of common sense and learning ability. Either way,
ignoring it seems the best idea.

Richard
Jul 6 '07 #16
On Jul 6, 7:05 pm, r...@hoekstra-uitgeverij.nl (Richard Bos) wrote:
Francine.Ne...@googlemail.com wrote:
On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.

The OP is either a more subtle and consistent troll than usual, or
entirely bereft of common sense and learning ability. Either way,
ignoring it seems the best idea.
Since you won't participate in the discussion or help the OP out of
the trouble, why can't you send Francine.Ne a personal email to remind
him about this, or just shut up?

Jul 6 '07 #17
lovecreatesbea...@gmail.com wrote:
i = i++;
Run away! Run away!

No, not /that/ way! Toward the FAQ!
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
(fx:applause)

"May" is a tad on the weak side, though.
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
No. You're not right.

It's /possible/ that `i` is increased by 1. It's /possible/ that
it's decreased by 2. It's /possible/ that it's set to zero, or
bitwise-inverted, or that an exception is thrown, or that execution
is halted, or that all local variables are cleared, or that it
prints the message "The rest is silence", or that your executable
is deleted, or that your display crashes.

Anything. It's all permitted by the standard. Anything. It doesn't
even have to be physically possible.

--
Anything Hedgehog
"Our future looks secure, but it's all out of our hands"
- Magenta, /Man and Machine/

Jul 6 '07 #18
"lovecreatesbea...@gmail.com" wrote:
Richard Heathfield <r...@see.sig.invalidwrote:
.... snip ...
>>
Please don't feed the trolls. This guy has been around clc for
quite long enough (like, years) that he ought to know by now
where to find the FAQ, and that he must have learned the answer
to his question a dozen times or more.

Man, why do you always keep angry? Can you be reasonable? Are
you the god on the net?
You seem to have problems distinguishing anger from advice.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #19
Richard Bos wrote:
Fr************@googlemail.com wrote:
.... snip ...
>>
What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to
find out - this is new territory for C-programming humanity.

The OP is either a more subtle and consistent troll than usual, or
entirely bereft of common sense and learning ability. Either way,
ignoring it seems the best idea.
'lovecreatesbeauty' just attained my PLONK list. Bye-bye.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #20
Chris Dollin wrote:
[big snip]

Please, let me quote what I think is one of the best things I read on
clc so far about the results of invoking UF ...
Anything. It doesn't even have to be physically possible.
Beautiful!

--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jul 6 '07 #21
On Jul 6, 8:44 pm, CBFalconer <cbfalco...@yahoo.comwrote:
Richard Bos wrote:
Francine.Ne...@googlemail.com wrote:

... snip ...
What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to
find out - this is new territory for C-programming humanity.
The OP is either a more subtle and consistent troll than usual, or
entirely bereft of common sense and learning ability. Either way,
ignoring it seems the best idea.

'lovecreatesbeauty' just attained my PLONK list. Bye-bye.
This can be done immediately and silently, and no need to let me (or
anybody) know actually.

Jul 6 '07 #22
On Jul 6, 11:00 pm, Keith Thompson <k...@mib.orgwrote:
"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrites:
On Jul 6, 1:34 pm, Keith Thompson <k...@mib.orgwrote:
"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrites:
i = i++;
<http://www.c-faq.com/>, question 3.3.
Sheesh.
I had this question when I was reading the c-faq. As for
i = i++;
I ever thought it works in following two ways.
1.
i = i /*no sequencing point followed immediately*/
i++
; /*sequencing point */
So, result: i = i + 1;
2.
i++ /*no sequencing point followed immediately,
but will the increasing effect be lost?*/
i = i /*i was assigned to itself*/
; /*sequencing point */
So, result: i = i;
And the result isn't certain.
Do I think it correctly?

Ok, I'll give this one last try.

No, you do not think it correctly. The behavior of 'i = i++;' is
undefined, because it attempts to modify the same object twice between
sequence points (C99 6.5p2). The phrase "undefined behavior" means
<snip>
The standard places *no requirements* on the behavior of 'i = i ++;'.
It may increment i, it may not increment i, it may cause your computer
to burst into flames, it may make demons fly out of your nose.

You say you had a question about this while reading the FAQ. Question
3.3 says the behavior of that particular expression is undefined. It
refers to question 3.9 explains what undefined behavior means.

I am at a loss to understand why you're having difficulty with this,
especially considering how long you've been participating in this
newsgroup.
Both items just say "it's undefined", or "it's bad", or "it isn't
correct". If they are good enough faqs, they should give more rational
and deeper explanation on it. Evan Einstein has some problems with
high school mathematics assignment, right?
People are being rude to you because they are frustrated at your
repeated asking of questions that have already been clearly answered.
Some people are assuming that you're doing this deliberately, to be
annoying. I'm not *yet* ready to make that assumption.
Thank you first.

You just can do anything you want to do, I think.

I'm wondering on the internet asking for help from kind and
knowledgeable people. I'm not rude to people, right? I don't sit at
one's home, right?

Jul 6 '07 #23
"lovecreatesbea...@gmail.com" wrote:
[...]
Don't you think the following program prints 11 on any or your system?
Isn't it portable?

int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;
}
On my old DS-6000, it hard-locks the computer. I understand that
the newer DS-9000 "fixes" this and gives a "bus error" instead.
(Though I may be mistaken. Perhaps someone with a spare DS-9000
and a scratch monkey can test it out?)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jul 6 '07 #24
"lovecreatesbea...@gmail.com" wrote:
[...]
I had this question when I was reading the c-faq. As for

i = i++;

I ever thought it works in following two ways.

1.
i = i /*no sequencing point followed immediately*/
i++
; /*sequencing point */

So, result: i = i + 1;

2.
i++ /*no sequencing point followed immediately,
but will the increasing effect be lost?*/
i = i /*i was assigned to itself*/
; /*sequencing point */

So, result: i = i;

And the result isn't certain.

Do I think it correctly?
What happens on a computer where "store i in i" and "increment i"
are done in parallel?

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jul 6 '07 #25
lovecreatesbea...@gmail.com wrote:
On Jul 6, 11:57 am, Francine.Ne...@googlemail.com wrote:
>On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"

<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?

What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.

Don't you think the following program prints 11 on any or your system?
Isn't it portable?
No, it doesn't print 11 on my system, and it isn't portable. Depending on
the options of the compiler I used, I can either get an error message for
the invalid implicit declaration of printf, or output of 10. (And these are
not the only other possible behaviours, as others have very clearly stated
already.)
int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;
}
Jul 6 '07 #26
lovecreatesbea...@gmail.com wrote:
i = i++;

The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
*plonk*

Brian
Jul 6 '07 #27
On Jul 6, 12:32 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
On Jul 6, 11:57 am, Francine.Ne...@googlemail.com wrote:
On Jul 6, 4:25 am, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
i = i++;
The gcc gives out a warning on this line of code, saying "warning:
operation on `i' may be undefined".
But I think, at the end of the execution of the statement, the
variable i is eventually increased by one, am I right?
What an original post! No one's ever thought to ask whether i=i++
makes sense before. No point searching Google or the C FAQ to find out
- this is new territory for C-programming humanity.

Don't you think the following program prints 11 on any or your system?
Isn't it portable?

int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;

}
Yeah, I know I'm feeding the troll. This isn't for him.

I once explored all the permutations of i++ + i++, i++ + ++i, etc., on
both a Windows system (Visual Studio, PIII, NT 4) and a Mac (MPW, PPC,
OS 9). Each got at least two answers "wrong", and the wrong answers
differed between the two systems.

So, no, the above program is not portable, and if it manages to print
11 on any system, it's due to dumb luck, not design.

Jul 6 '07 #28
Pietro Cerutti wrote, On 06/07/07 14:45:
Chris Dollin wrote:
[big snip]

Please, let me quote what I think is one of the best things I read on
clc so far about the results of invoking UF ...
UF? I think you mean UB.
>Anything. It doesn't even have to be physically possible.

Beautiful!
http://groups.google.co.uk/group/com...175076ae99a1c5

There are plenty of other examples on the group, and sometimes people
are quite imaginative in their suggestions.
--
Flash Gordon
Jul 6 '07 #29
"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrites:
On Jul 6, 11:00 pm, Keith Thompson <k...@mib.orgwrote:
[...]
>I am at a loss to understand why you're having difficulty with this,
especially considering how long you've been participating in this
newsgroup.

Both items just say "it's undefined", or "it's bad", or "it isn't
correct". If they are good enough faqs, they should give more rational
and deeper explanation on it. Evan Einstein has some problems with
high school mathematics assignment, right?
Question 3.9 in the FAQ says:

More significantly, once an expression or program becomes
undefined, *all* aspects of it become undefined. When an
undefined expression has (apparently) two plausible
interpretations, do not mislead yourself by imagining that the
compiler will choose one or the other. The Standard does not
require that a compiler make an obvious choice, and some compilers
don't. In this case, not only do we not know whether a[i] or
a[i+1] is written to, it is possible that a completely unrelated
cell of the array (or any random part of memory) is written to,
and it is also not possible to predict what final value i will
receive.

That seems more than clear enough to me. And yet you misled yourself
by imagining that the compiler will choose one or the other.

There's absolutely no reason to write 'i = i++;' anyway. If you want
to increment 'i', just write 'i ++;'. That already assigns the result
to i; why do it again?
>People are being rude to you because they are frustrated at your
repeated asking of questions that have already been clearly answered.
Some people are assuming that you're doing this deliberately, to be
annoying. I'm not *yet* ready to make that assumption.

Thank you first.

You just can do anything you want to do, I think.

I'm wondering on the internet asking for help from kind and
knowledgeable people. I'm not rude to people, right? I don't sit at
one's home, right?
No, but you asked a question that has been asked and answered many
many times, and that is answered quite clearly in the FAQ.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '07 #30
On Fri, 06 Jul 2007 13:00:43 -0400, in comp.lang.c , Kenneth Brody
<ke******@spamcop.netwrote:
>On my old DS-6000, it hard-locks the computer. I understand that
the newer DS-9000 "fixes" this and gives a "bus error" instead.
(Though I may be mistaken. Perhaps someone with a spare DS-9000
and a scratch monkey can test it out?)
Thanks for nothing - now my monkey is suing me after my DS9K fired a
small branding iron out of the disk drive slot which burnt the words
""arg, your wife is a big hippo" on his hide. Apparently thats the new
bus error signal.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '07 #31
On Fri, 06 Jul 2007 16:59:43 -0000, in comp.lang.c ,
"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrote:
>On Jul 6, 11:00 pm, Keith Thompson <k...@mib.orgwrote:
>I am at a loss to understand why you're having difficulty with this,
especially considering how long you've been participating in this
newsgroup.

Both items just say "it's undefined", or "it's bad", or "it isn't
correct". If they are good enough faqs, they should give more rational
and deeper explanation on it.
Whats to explain? Its undefined - the explanation is that the C
standard says so.

Do you expect a dictionary to explain why meaningless words are
meaningless? Or an atlas to say why nonexistent places are
nonexistent? This isn't philosophy 101.

If, by chance, you meant "why does the C standard say this construct
is not defined by the C language?" then why not ask that question?

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '07 #32
On Fri, 06 Jul 2007 02:01:02 -0700, in comp.lang.c ,
"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrote:
>On Jul 6, 3:44 pm, Flash Gordon <s...@flash-gordon.me.ukwrote:
>ranjeet.gu...@gmail.com wrote, On 06/07/07 06:45:
lovecreatesbea...@gmail.com wrote:
>By the way, since the OP has been around for a long time off and on yet
is asking the question I think it is either a troll or fundamentally
incapable of learning to program in C. The meaning of undefined
behaviour was even explained to the OP back in 2005http://groups.google.co.uk/group/comp.lang.c/browse_frm/thread/2b0e0f...

Why are you so impolite and unkind to people?
The above comment is neither impolite nor unkind. If, after two years
of asking the same questions, you still haven't got it, you really
aren't capable of learning C.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '07 #33
>Don't you think the following program prints 11 on any or your system?

I think it ought to delete it's own source code, and it could happen
in some implementation.
>Isn't it portable?
No.
>>
int main(void)
{
int i;
i = 10;
i = i++;
printf("%d\n", i);
return 0;
}

On my old DS-6000, it hard-locks the computer. I understand that
the newer DS-9000 "fixes" this and gives a "bus error" instead.
"bus error" is shorthand for saying it blows up a busload of children.
Possibly yours.
>(Though I may be mistaken. Perhaps someone with a spare DS-9000
and a scratch monkey can test it out?)
Where do I get a "scratch planet"?
Jul 7 '07 #34
>Yeah, I know I'm feeding the troll. This isn't for him.
>
I once explored all the permutations of i++ + i++, i++ + ++i, etc., on
both a Windows system (Visual Studio, PIII, NT 4) and a Mac (MPW, PPC,
OS 9). Each got at least two answers "wrong", and the wrong answers
differed between the two systems.
There are *NO* wrong answers here.
>So, no, the above program is not portable, and if it manages to print
11 on any system, it's due to dumb luck, not design.
Or it could be malevolent design.

Jul 7 '07 #35
On Jul 7, 5:46 am, Mark McIntyre <markmcint...@spamcop.netwrote:
On Fri, 06 Jul 2007 16:59:43 -0000, in comp.lang.c ,

"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrote:
On Jul 6, 11:00 pm, Keith Thompson <k...@mib.orgwrote:
I am at a loss to understand why you're having difficulty with this,
especially considering how long you've been participating in this
newsgroup.
Both items just say "it's undefined", or "it's bad", or "it isn't
correct". If they are good enough faqs, they should give more rational
and deeper explanation on it.

Whats to explain? Its undefined - the explanation is that the C
standard says so.

Do you expect a dictionary to explain why meaningless words are
meaningless? Or an atlas to say why nonexistent places are
nonexistent? This isn't philosophy 101.

If, by chance, you meant "why does the C standard say this construct
is not defined by the C language?" then why not ask that question?
Thank you. I really wanted to ask that question. I'm not a native
English speaker. The question hasn't been presented in that way,
because I don't have a good expression skill in English, and didn't
organize my words very well at that time.

Jul 7 '07 #36
On Jul 7, 5:47 am, Mark McIntyre <markmcint...@spamcop.netwrote:
On Fri, 06 Jul 2007 02:01:02 -0700, in comp.lang.c ,

"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrote:
On Jul 6, 3:44 pm, Flash Gordon <s...@flash-gordon.me.ukwrote:
ranjeet.gu...@gmail.com wrote, On 06/07/07 06:45:
lovecreatesbea...@gmail.com wrote:
By the way, since the OP has been around for a long time off and on yet
is asking the question I think it is either a troll or fundamentally
incapable of learning to program in C. The meaning of undefined
behaviour was even explained to the OP back in 2005http://groups.google.co.uk/group/comp.lang.c/browse_frm/thread/2b0e0f...
Why are you so impolite and unkind to people?

The above comment is neither impolite nor unkind. If, after two years
of asking the same questions, you still haven't got it, you really
aren't capable of learning C.
Can you show me how capable on learning C? Can you show me how capable
you are on programming in C? Have you done another Unix, Linux or
Windows alone? Show me some evidence? Don't let think you aren't
capable of learning C also.

Jul 7 '07 #37
lovecreatesbea...@gmail.com said:
On Jul 7, 5:47 am, Mark McIntyre <markmcint...@spamcop.netwrote:
>"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrote:
<snip>
>Why are you so impolite and unkind to people?

The above comment is neither impolite nor unkind. If, after two years
of asking the same questions, you still haven't got it, you really
aren't capable of learning C.

Can you show me how capable on learning C?
Mark McIntyre knows C far better than most people - because he takes the
time and trouble to read and understand much of what is posted in
comp.lang.c - and he need have no fear that he needs to justify his
competence in C to someone who has been failing to learn the basics for
over two years.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 7 '07 #38
On Jul 7, 2:21 am, Keith Thompson <k...@mib.orgwrote:
"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrites:
On Jul 6, 11:00 pm, Keith Thompson <k...@mib.orgwrote:
[...]
I am at a loss to understand why you're having difficulty with this,
especially considering how long you've been participating in this
newsgroup.
Both items just say "it's undefined", or "it's bad", or "it isn't
correct". If they are good enough faqs, they should give more rational
and deeper explanation on it. Evan Einstein has some problems with
high school mathematics assignment, right?

Question 3.9 in the FAQ says:

More significantly, once an expression or program becomes
undefined, *all* aspects of it become undefined. When an
undefined expression has (apparently) two plausible
interpretations, do not mislead yourself by imagining that the
compiler will choose one or the other. The Standard does not
require that a compiler make an obvious choice, and some compilers
don't. In this case, not only do we not know whether a[i] or
a[i+1] is written to, it is possible that a completely unrelated
cell of the array (or any random part of memory) is written to,
and it is also not possible to predict what final value i will
receive.

That seems more than clear enough to me. And yet you misled yourself
by imagining that the compiler will choose one or the other.

There's absolutely no reason to write 'i = i++;' anyway. If you want
to increment 'i', just write 'i ++;'. That already assigns the result
to i; why do it again?
I come to you again with a different question but related to the
original one.

"why does the C standard say this construct is not defined by the C
language?"

Thank you for your time. (am i supposed to get the same answer - "it's
undefined" again :=) )

Jul 7 '07 #39
On Jul 7, 2:17 pm, Richard Heathfield <r...@see.sig.invalidwrote:
lovecreatesbea...@gmail.com said:
On Jul 7, 5:47 am, Mark McIntyre <markmcint...@spamcop.netwrote:
"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrote:

<snip>
Why are you so impolite and unkind to people?
The above comment is neither impolite nor unkind. If, after two years
of asking the same questions, you still haven't got it, you really
aren't capable of learning C.
Can you show me how capable on learning C?

Mark McIntyre knows C far better than most people - because he takes the
time and trouble to read and understand much of what is posted in
comp.lang.c - and he need have no fear that he needs to justify his
competence in C to someone who has been failing to learn the basics for
over two years.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
yeah, that's so, and same as you? I ever thought he (and/or you) is
going to own microsoft, for you all are so capable of anything.

(I just wonder why your killfile doesn't work and send a unwanted
response to me directly.)

Jul 7 '07 #40
lovecreatesbea...@gmail.com said:

<snip>
"why does the C standard say this construct is not defined by the C
language?"
The answer has not changed since the last time this question was asked.
The Standard says:

"Between the previous and next sequence point an object shall have
its stored value modified at most once by the evaluation of an
expression. Furthermore, the prior value shall be accessed only to
determine the value to be stored."

By restricting programs in this way, the Standard gives compilers
considerable freedom in optimising code to make it run as fast as they
can manage. The price you pay for that speed is discipline.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 7 '07 #41
lovecreatesbea...@gmail.com wrote:
On Jul 6, 8:44 pm, CBFalconer <cbfalco...@yahoo.comwrote:
>'lovecreatesbeauty' just attained my PLONK list. Bye-bye.

This can be done immediately and silently, and no need to let me (or
anybody) know actually.
That's not for /you/ to say.

--
Hedgehog
Scoring, bah. If I want scoring I'll go play /Age of Steam/.

Jul 7 '07 #42
lovecreatesbea...@gmail.com said:
On Jul 7, 2:17 pm, Richard Heathfield <r...@see.sig.invalidwrote:
>lovecreatesbea...@gmail.com said:
On Jul 7, 5:47 am, Mark McIntyre <markmcint...@spamcop.netwrote:
"lovecreatesbea...@gmail.com" <lovecreatesbea...@gmail.comwrote:

<snip>
>Why are you so impolite and unkind to people?
>The above comment is neither impolite nor unkind. If, after two
years of asking the same questions, you still haven't got it, you
really aren't capable of learning C.
Can you show me how capable on learning C?

Mark McIntyre knows C far better than most people - because he takes
the time and trouble to read and understand much of what is posted in
comp.lang.c - and he need have no fear that he needs to justify his
competence in C to someone who has been failing to learn the basics
for over two years.

yeah, that's so, and same as you?
Do your research.

I ever thought he (and/or you) is
going to own microsoft, for you all are so capable of anything.
I don't *want* to own Microsoft. It would be like owning hell.
(I just wonder why your killfile doesn't work and send a unwanted
response to me directly.)
I haven't specifically killfiled *you*, although many people here have
done so. I have, however, downscored *all* gmail users, of which you
are one, except for a list of gmail users that I happen to know to be
bright (and you are not on that list). Consequently, whether I see your
article at all depends on whether I'm using a scoring filter or not,
which I sometimes do and sometimes don't. At present, the scoring
filter is off, but it's easy enough to put it on.

It's not exactly killfiling, but if I plonk someone, that's basically
what happens - I /probably/ won't get to see their articles, but I
/might/. And of course I have the same right of reply as anyone else,
even to people I have killfiled - although normally I don't bother to
exercise it because normally the reason they've been killfiled is that
they're behaving in an uncivilised way, and there's no reasoning with
such people.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 7 '07 #43
lovecreatesbea...@gmail.com wrote:
On Jul 7, 5:46 am, Mark McIntyre <markmcint...@spamcop.netwrote:
>On Fri, 06 Jul 2007 16:59:43 -0000, in comp.lang.c ,
>If, by chance, you meant "why does the C standard say this construct
is not defined by the C language?" then why not ask that question?

Thank you. I really wanted to ask that question. I'm not a native
English speaker. The question hasn't been presented in that way,
because I don't have a good expression skill in English, and didn't
organize my words very well at that time.
It's undefined because (a) it's pointless, (b) when C was standardised
different compilers would compile it different ways, (c) it gives
manoeuvering room to code-generation that was seen to essential
for efficient code generation.

That's my reading.

--
Defined Hedgehog
A rock is not a fact. A rock is a rock.

Jul 7 '07 #44
"Richard Heathfield" writes:
lovecreatesbea...@gmail.com said:
>(I just wonder why your killfile doesn't work and send a unwanted
response to me directly.)

I haven't specifically killfiled *you*, although many people here have
done so. I have, however, downscored *all* gmail users, of which you
are one, except for a list of gmail users that I happen to know to be
bright (and you are not on that list). Consequently, whether I see your
article at all depends on whether I'm using a scoring filter or not,
which I sometimes do and sometimes don't. At present, the scoring
filter is off, but it's easy enough to put it on.

It's not exactly killfiling, but if I plonk someone, that's basically
what happens - I /probably/ won't get to see their articles, but I
/might/. And of course I have the same right of reply as anyone else,
even to people I have killfiled - although normally I don't bother to
exercise it because normally the reason they've been killfiled is that
they're behaving in an uncivilised way, and there's no reasoning with
such people.
I have the belief that the vast majority of *PLONKS* I see, not from you
especially, are virtual rather than real.
Jul 7 '07 #45
"Keith Thompson" writes:
First off, the exact rule we're talking about (C99 6.5p2) is:

Between the previous and next sequence point an object shall have
its stored value modified at most once by the evaluation of an
expression. Furthermore, the prior value shall be read only to
determine the value to be stored.

with a footnote:

This paragraph renders undefined statement expressions such as

i = ++i + 1;
a[i++] = i;

while allowing

i = i + 1;
a[i] = i;

Sequence points occur in a number of places: between statements (you
can loosely think of a ';' as marking a sequence point), between the
operands of a ',', '&&', or '||' operator, and in a number of other
places.
<snip>

What is going on here? A real answer? After only 55 or so posts?
Jul 7 '07 #46
osmium said:

<snip>
I have the belief that the vast majority of *PLONKS* I see, not from
you especially, are virtual rather than real.
Yes, you're probably right. More so in my case, perhaps, for the reason
already explained, except that I *am* training myself - slowly - not to
reply to people for whom KNode has recorded a negative score. I am of
the opinion that a plonk should be for life, not just for Christmas.
(Unless it's a timed plonk, the "sin-bin" kind. I have to work on the
timing there. 30 days seems rather long, and 40 is interminable.)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 7 '07 #47
osmium said:

<snip>
>
What is going on here? A real answer? After only 55 or so posts?
The real answer has been posted dozens of times in the last two years.
The OP has no grounds for complaint on that score.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 7 '07 #48
osmium wrote:

I have the belief that the vast majority of PLONKS I see, not from
you especially, are virtual rather than real.
Do you have any evidence for that around here?

I guarantee that any I issue are real. I do, however, have home and
work setups. There are sometimes that I don't recall that some person
or the other plonked at one location needs to be added at the other,
although usually a reminder is issued by a further stupid posting.

Brian
Jul 7 '07 #49
"osmium" <r1********@comcast.netwrites:
"Keith Thompson" writes:
>First off, the exact rule we're talking about (C99 6.5p2) is:

Between the previous and next sequence point an object shall have
its stored value modified at most once by the evaluation of an
expression. Furthermore, the prior value shall be read only to
determine the value to be stored.
[snip]
>
What is going on here? A real answer? After only 55 or so posts?
A real answer had to await a real question.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 7 '07 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
1
by: Roy | last post by:
Hey all. All I'm trying to do is get a darn double solid bar in my datagrid footer. Doesn't seem to work. Any tips? The weird thing is all the other stylesheet attributes work. If I increase the...
0
by: cedoucette | last post by:
I just wrote code to support sortable columns in a datagrid. It seems to work fine; but, it doesn't look right. The problem is that I have a generic style for links and a different style for the...
1
by: RonY | last post by:
I have a dropdown which calls SetTimePeriod method on change the selection. In the JS function, I reset the field style.display based on what the selection is. This works fine with IE but not working...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
6
by: rongchaua | last post by:
Hi all, I want to change the style of a button. But I don't know how to do it. For example, I have already a button OK on form. I want to add these styles to this button (WS_CHILD || WS_VISIBLE ||...
1
by: Armin Gajda | last post by:
Hi, I have the following problem: An input field get a border assigned by a style class (e.g. 2px solid red). When the field gets the focus, we set the border to green. element.style.border...
0
by: =?Utf-8?B?QXR1bA==?= | last post by:
When .Net 1.0 webservice (VS2003) generates a wsdl - <wsdl:binding name="TestSoap" type="tns:TestSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/(note:...
3
by: Michellevt | last post by:
Hi I am working on a project (for college) and wondered if anyone can help me with my problem. In the project we are not allowed to make use of any "style" attributes but "class" attributes...
3
Claus Mygind
by: Claus Mygind | last post by:
I want to move some style setting into a javaScript function so I can make them variable but I get "invalid assignment left-hand side" error? see my question at the bottom of this message. It...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.