On Tue, 27 Dec 2005 22:39:54 +0000, Christian Bau
<christian.bau@cbau.freeserve.co.uk> wrote in comp.lang.c:
[color=blue]
> In article <ct73r19n4b87evod83ad1kcbrjhf0l4bdr@4ax.com>,
> Jack Klein <jackklein@spamcop.net> wrote:
>[color=green]
> > 'a' is an unsigned long, and unsigned types can't overflow. I suppose
> > the question you are really asking is, what happens if 'a' contains a
> > value larger than LONG_MAX.
> >
> > In that case, either 'b' receives an implementation-defined value or
> > an implementation-defined signal is raised.[/color]
>
> Do you know if it is implementation-defined which one will happen? So an
> implementation has to specify that either there will _always_ be an
> implementation defined value or _always_ an implementation-defined
> signal?[/color]
No, I don't. The "implementation-defined signal" option did not exist
prior to C99. The one time I can remember the question being asked on
comp.std.c, no one who responded claimed to know of any such system.
One committee member wrote something about not constraining future
implementations.
As to whether the implementation is required to do the same thing for
all integer types, I am not so sure.
Consider an architecture with 32 bit registers that implemented
int64_t and uint64_t using its floating point hardware, which is not
particularly far-fetched since one could do this on anything in the
x86 family from the 486DX on up.
Such an implementation could specify the "expected"
implementation-defined behavior of bit truncation for the types up to
and including int32_t, but specify that it would throw a signal on
converting an out-of-range double to an int64_t. If the floating
point hardware generated an exception on out-of-range conversion, the
compiler run time would need to trap it and throw a C signal.
I have no idea whether such an implementation ever has or ever will
exist.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html