M
Mark B
Wow, I thought this part of the thread died a week ago with my last post...
took you long enough to respond
(btw: was out friday and don't work weekends which is why it took me a few
days to respond
Possibly. Though I am not a pedant so I do sometimes respond
to what I perceive people to 'mean' rather than what they actually
do say... but that can be a good thing! Too many posters on clc
get blasted for not phrasing their legitimate questions appropriately...
while others can get their homework problems completed within
minutes as long as they word their posts properly! clc might be
a better place if some of the pedants were a little more lenient.
I must be missing something... how can it result in
undefined behavior with no overflow?
Correct, not one post in this particular branch of the thread
had ever declared any of the variables.
Check again, maybe else-thread, but not in this particular
branch.
I thought I did... by posting what I thought to be the relevent
section from the (draft) standard.
And then again when I responded to your rebuttal with:
None of the earlier posts specified ANY type.
Follow this thread back to the OP and you'll see that.
<q>No, it also states that unsigned integer types DO behave a certain
You keep referring to this earlier post in which the
variables were declared... maybe my newsreader missed a
few messages... whose post, and when? Maybe I'll be able
to find it using google, because I certainly didn't get it here.
Am I the only poster in clc using the draft?
I'm suprised to find that they've added a function they don't
mention in the final draft... maybe I should spend the $18
to see what else I'm missing
Yes, and I stated that I assumed you were referring to the
'ceil functions' - isn't that still the appropriate terminology?
It is according to the final draft, maybe they changed it between
then and the final version Does a word search on 'ceiling'
return anything in the final version of the standard? If so, I may
have to spend the $18 - otherwise the final draft may still do
me just fine.
Actually, the pronunciation of function names may make a
good sub-thread... I haven't seen one of those in a few years!
(then again, I had taken a few years off from comp-lang-c and
only recently returned, maybe I just missed it!)
A)
strcpy = stir copy
ceil = seal
fprintf = ef print ef
B)
strcpy = string copy
ceil = ceiling
fprintf = file print file
I belong to group A.
Which group do you (anyone) prefer? A? B?
I'm sure we'll get a bunch of people making
up their own group 'C' too, let's see them!
Regards,
Mark
took you long enough to respond
(btw: was out friday and don't work weekends which is why it took me a few
days to respond
Tim Rentsch said:Mark said:Then why are we having this discussion?Tim Rentsch said:[snip]
As far as I understand, overflow/underflow invokes behaviour not
covered
by the standard, which may include setting all bits to zero.
I thought it was covered... no?
H.2.2 Integer types
[#1] The signed C integer types int, long int, long long
int, and the corresponding unsigned types are compatible
with LIA-1. If an implementation adds support for the LIA-1
exceptional values integer_overflow and undefined, then
those types are LIA-1 conformant types. C's unsigned
integer types are ``modulo'' in the LIA-1 sense in that
overflows or out-of-bounds results silently wrap. An
implementation that defines signed integer types as also
being modulo need not detect integer overflow, in which
case, only integer divide-by-zero need be detected.
Maybe I'm misreading something...
First: Appendix H is informative rather than normative.
Second: The paragraph above only says that signed integer
types *may* behave in a certain way
No, it also states that unsigned integer types DO behave a certain
way.
The subject in question is overflow (or underflow), which
usually is understood to refer to signed integer types rather
than unsigned integer types.
Apparently, because you haven't been able to express
yourself clearly, because you respond to what you imagine
people are saying rather than what they actually do say, and
because you make statements that either are poorly worded or
just plain wrong;
Touche.
and also because I've been optimistic
enough to think that one or more of those might change
sometime soon.
Possibly. Though I am not a pedant so I do sometimes respond
to what I perceive people to 'mean' rather than what they actually
do say... but that can be a good thing! Too many posters on clc
get blasted for not phrasing their legitimate questions appropriately...
while others can get their homework problems completed within
minutes as long as they word their posts properly! clc might be
a better place if some of the pedants were a little more lenient.
The comment I think you're referring to is one you made in
an earlier post that isn't quoted above; namely:
As written this statement is wrong. The expression in the
'if' certainly can overflow. It also can result in
undefined behavior even if the subtraction operators don't
result in overflow.
I must be missing something... how can it result in
undefined behavior with no overflow?
If you meant to say, "this expression can't result in
overflow, because the operands are 'unsigned'", there's
nothing to support that statement. In no posting in the
thread were any variables declared having any unsigned
integer type.
Correct, not one post in this particular branch of the thread
had ever declared any of the variables.
On the other hand, several postings did
declare variables of *signed* integer type, including
variables that participated in the comparison (as might be
represented by a,b,c, etc, in the 'if' above).
Check again, maybe else-thread, but not in this particular
branch.
If you meant to say, "this expression can't result in
overflow, because the '|' operators mean the values must be
unsigned", that's wrong.
If you meant to say, "as long as the variables are of some
unsigned integer type, overflow can't happen", that may be
true, but not really very relevant, since there still is
the possibility of undefined behavior.
How?
If you meant to say, "*if* the operands are all of type
'unsigned int', then no overflow or undefined behavior can
occur", that's true, but then why didn't you just say that?
I thought I did... by posting what I thought to be the relevent
section from the (draft) standard.
And then again when I responded to your rebuttal with:
No, it also states that unsigned integer types DO behave a certain way.
There is nothing in your posting (the one that has the
excerpt above) that says anything about any unsigned type,
let along 'unsigned int', either in your text or what was
included from other posters. Nor does your earlier posting
(the original one that has the 'if(a-b|...' in it) say
anything about any unsigned type.
None of the earlier posts specified ANY type.
Follow this thread back to the OP and you'll see that.
You may imagine that the operands were "bit operands", but
there is nothing in what you wrote to indicate that;
<q>No, it also states that unsigned integer types DO behave a certain
way. said:and,
to the contrary in earlier postings when variables were
declared as 'int' rather than 'unsigned int'.
You keep referring to this earlier post in which the
variables were declared... maybe my newsreader missed a
few messages... whose post, and when? Maybe I'll be able
to find it using google, because I certainly didn't get it here.
Impossible, there is no such function in the C language. [snip][snip]>
In my document [ISO/IEC 9899:1999 (E)], 3.18 is a definition of
the ceiling function.
It's not only possible, if you get a copy of the C standard
document mentioned above, you'll see that it's true.
Am I the only poster in clc using the draft?
I'm suprised to find that they've added a function they don't
mention in the final draft... maybe I should spend the $18
to see what else I'm missing
You *should* know what I'm reading; the reference number
for the document is given above. Presumably what you meant
to say is that you don't know what text is contained in what
I'm reading, and I expect that's true. But you could find
out by getting a copy of the document and reading it yourself.
Incidentally, note that I said 3.18 is a definition of the
ceiling function, not the 'ceiling' function.
Yes, and I stated that I assumed you were referring to the
'ceil functions' - isn't that still the appropriate terminology?
It is according to the final draft, maybe they changed it between
then and the final version Does a word search on 'ceiling'
return anything in the final version of the standard? If so, I may
have to spend the $18 - otherwise the final draft may still do
me just fine.
Actually, the pronunciation of function names may make a
good sub-thread... I haven't seen one of those in a few years!
(then again, I had taken a few years off from comp-lang-c and
only recently returned, maybe I just missed it!)
A)
strcpy = stir copy
ceil = seal
fprintf = ef print ef
B)
strcpy = string copy
ceil = ceiling
fprintf = file print file
I belong to group A.
Which group do you (anyone) prefer? A? B?
I'm sure we'll get a bunch of people making
up their own group 'C' too, let's see them!
Regards,
Mark