Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37930

Re: Unexpected Boxing Error at Runtime

From Daniele Futtorovic <da.futt.news@laposte.net>
Newsgroups comp.lang.java.programmer
Subject Re: Unexpected Boxing Error at Runtime
Date 2018-01-06 00:06 +0100
Organization A noiseless patient Spider
Message-ID <p2p0fm$n1g$1@dont-email.me> (permalink)
References (4 earlier) <p2m48h$149e$1@gioia.aioe.org> <p2o4ba$46d$1@dont-email.me> <7mev4dhc2dj9l1i2j8f6n0bn5a6s2f56ko@4ax.com> <p2olhr$75l$1@dont-email.me> <p2oqkn$ceb$1@dont-email.me>

Show all headers | View raw


On 2018-01-05 22:27, Eric Sosman wrote:
> On 1/5/2018 2:59 PM, Daniele Futtorovic wrote:
>> On 2018-01-05 18:51, Gene Wirchenko wrote:
>>>       VB 6 defaulted to checking for overflow; this might have just
>>> been for integer types.  I liked that.  It is far better to find out
>>> about the error sooner rather than later if ever.
>>
>> YMMV. If I use an integer, I know it might overflow. If I don't want
>> that, I'll guard against it. I find it borderline insulting when the
>> language takes that decision away from me. What help is the exception
>> gonna be in making the program recover, anyway? Yes, it will help to
>> detect the error. But that only means one hasn't thought things through
>> in the first place.
> 
>     Tastes vary, I guess.  For my part, I would like it if integer
> overflow/underflow raised some kind of alert, warning me that one of
> my calculations had produced the wrong answer.  See
> 
> https://research.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html
> 
> 
> ... for an account (somewhat sensationalized and overexcited) of a bug
> that lay latent for nearly a decade but that would have been exposed
> much more clearly had integer overflow been noisier.  (Bloch's remarks
> about C, even in the "corrected" version, are not quite on the mark.
> Also, it is interesting to note that C's "K&R Classic" book from 1978
> illustrates a binary search that is *not* vulnerable to the paper's bug.
> His point about undetected overflow, however, remains.)

Yeah, I remember reading about that one. The lesson -- humility and the
need for attention to detail -- is certainly a valuable one, and not
limited to overflows.

As you say, tastes vary. Personally, I've taken that habit, whenever I
do integral manipulations, to pause and think of potential overflow. If
I'd written that line in the binary search, I think I would have caught
it (so much for humility ;)). Then again, perhaps I only took that habit
/because/ such lessons cropped up and I heard of them.

I don't mean to sound dogmatic here. Having things that can, if you
want, shield you from making mistakes, at the end of the day, is a good
thing. I guess there's a bit of rancour left in me at that experience in
.NET, one of my first ones, where I had an int that I /wanted/ to
overflow, and felt quite clever about it, and then the runtime came
pissing on my parade like a ruffled mother hen. You could switch it off,
so it was all good, but still.

As for the detection, since there are cases where an overflow is fine,
you can't have the runtime alert you to it, save with the use of some
kind of directives -- compiler directives, annotations, what have you.
In that sense, if you want alerts, .NET's way is probably the only
practical one.

I still prefer Java's Live & Let Die, though. Keeps you on your toes.
-- 
DF.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Unexpected Boxing Error at Runtime j4n bur53 <janburse@fastmail.fm> - 2018-01-04 15:16 +0100
  Re: Unexpected Boxing Error at Runtime Eric Douglas <e.d.programmer@gmail.com> - 2018-01-04 07:04 -0800
  Re: Unexpected Boxing Error at Runtime Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-01-04 10:13 -0500
  Re: Unexpected Boxing Error at Runtime Eric Douglas <e.d.programmer@gmail.com> - 2018-01-04 08:01 -0800
    Re: Unexpected Boxing Error at Runtime Marcel Mueller <news.5.maazl@spamgourmet.org> - 2018-01-04 18:33 +0100
      Re: Unexpected Boxing Error at Runtime Kiwi User <martin@mydomain.invalid> - 2018-01-04 19:29 +0000
    Re: Unexpected Boxing Error at Runtime Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-01-04 15:09 -0500
      Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-04 21:43 +0100
        Re: Unexpected Boxing Error at Runtime Arne Vajhøj <arne@vajhoej.dk> - 2018-01-04 15:53 -0500
          Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-05 16:06 +0100
            Re: Unexpected Boxing Error at Runtime Gene Wirchenko <genew@telus.net> - 2018-01-05 09:51 -0800
              Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-05 20:59 +0100
                Re: Unexpected Boxing Error at Runtime Eric Douglas <e.d.programmer@gmail.com> - 2018-01-05 12:15 -0800
                Re: Unexpected Boxing Error at Runtime Kiwi User <martin@mydomain.invalid> - 2018-01-05 21:52 +0000
                Re: Unexpected Boxing Error at Runtime Gene Wirchenko <genew@telus.net> - 2018-01-08 11:13 -0800
                Re: Unexpected Boxing Error at Runtime Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-01-05 16:27 -0500
                Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-06 00:06 +0100
                Re: Unexpected Boxing Error at Runtime Kiwi User <martin@mydomain.invalid> - 2018-01-05 23:57 +0000
                Re: Unexpected Boxing Error at Runtime Arne Vajhøj <arne@vajhoej.dk> - 2018-01-07 20:06 -0500
                Re: Unexpected Boxing Error at Runtime bursejan@gmail.com - 2018-01-08 04:10 -0800
                Re: Unexpected Boxing Error at Runtime bursejan@gmail.com - 2018-01-08 04:31 -0800
                Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-08 16:25 +0100
                Re: Unexpected Boxing Error at Runtime Arne Vajhøj <arne@vajhoej.dk> - 2018-01-08 20:05 -0500
                Re: Unexpected Boxing Error at Runtime bursejan@gmail.com - 2018-01-08 17:55 -0800
                Re: Unexpected Boxing Error at Runtime Gene Wirchenko <genew@telus.net> - 2018-01-08 11:19 -0800
                Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-08 20:40 +0100
                Re: Unexpected Boxing Error at Runtime Gene Wirchenko <genew@telus.net> - 2018-01-08 18:03 -0800
                Re: Unexpected Boxing Error at Runtime Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-16 02:33 +0100
                Re: Unexpected Boxing Error at Runtime bursejan@gmail.com - 2018-01-22 14:26 -0800
                Re: Unexpected Boxing Error at Runtime bursejan@gmail.com - 2018-01-22 14:33 -0800
        Re: Unexpected Boxing Error at Runtime Arne Vajhøj <arne@vajhoej.dk> - 2018-01-04 19:16 -0500
          Re: Unexpected Boxing Error at Runtime Kiwi User <martin@mydomain.invalid> - 2018-01-05 12:17 +0000
  Re: Unexpected Boxing Error at Runtime j4n bur53 <janburse@fastmail.fm> - 2018-01-05 00:13 +0100
    Re: Unexpected Boxing Error at Runtime Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-01-05 11:05 -0500
      Re: Unexpected Boxing Error at Runtime bursejan@gmail.com - 2018-01-06 06:18 -0800

csiph-web