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


Groups > comp.lang.c++ > #84029

Re: This code is effective for modest-sized numbers, but can you tell what it does?

From Paavo Helde <eesnimi@osa.pri.ee>
Newsgroups comp.lang.c++
Subject Re: This code is effective for modest-sized numbers, but can you tell what it does?
Date 2022-05-10 20:34 +0300
Organization A noiseless patient Spider
Message-ID <t5e7no$bfv$1@dont-email.me> (permalink)
References <0c3601f0-fc8c-4bb9-a8b3-598ea1ca4a79n@googlegroups.com> <t45cmv$1omi$1@gioia.aioe.org> <86fsm18i1c.fsf@linuxsc.com> <t4652k$296$1@dont-email.me> <86mtfp4gjw.fsf@linuxsc.com>

Show all headers | View raw


10.05.2022 17:18 Tim Rentsch kirjutas:
> Paavo Helde <eesnimi@osa.pri.ee> writes:

>> So, in order to not lose these useful warnings in the avalanche of
>> non-useful ones, one should use matching types in such simple code,
>> it does not cost anything.
> 
> That seems plainly false.  Any change that incurs some programming
> effort and disturbs what code is written obviously costs something.
> A claim could be made that the cost is worth the benefit, but
> clearly the cost is greater than zero.

One can argue that it's using of mismatching types in a comparison which 
means non-zero programming effort.

If the types used in a comparison are of different types and especially 
of different signedness, the programmer needs to know the promotion 
rules which might depend on the operand sizes, which in turn might 
depend on the platform/implementation.

The programmer needs to think through what happens when the signed 
operand becomes negative. Is it possible and what happens then?

Even more to the point, when a maintenance programmer comes around and 
sees the code, they have to think it through again, every time. Why are 
incompatible types used in comparison? Was it an oversight and is it 
possible it might cause problems?

I will see that as a significant programming effort. YMMV.

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

This code is effective for modest-sized numbers, but can you tell what it does? "Graeme C." <graec58@gmail.com> - 2022-04-22 04:41 -0700
  Re: This code is effective for modest-sized numbers, but can you tell what it does? Christian Gollwitzer <auriocus@gmx.de> - 2022-04-22 17:19 +0200
    Re: This code is effective for modest-sized numbers, but can you tell what it does? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-04-22 17:42 +0200
      Re: This code is effective for modest-sized numbers, but can you tell what it does? red floyd <no.spam.here@its.invalid> - 2022-04-22 09:16 -0700
  Re: This code is effective for modest-sized numbers, but can you tell what it does? Frederick Gotham <cauldwell.thomas@gmail.com> - 2022-04-22 09:22 -0700
    Re: This code is effective for modest-sized numbers, but can you tell what it does? "Graeme C." <graec58@gmail.com> - 2022-04-22 10:24 -0700
      Re: This code is effective for modest-sized numbers, but can you tell what it does? Christian Gollwitzer <auriocus@gmx.de> - 2022-04-22 20:33 +0200
        Re: This code is effective for modest-sized numbers, but can you tell what it does? "Graeme C." <graec58@gmail.com> - 2022-04-22 17:57 -0700
  Re: This code is effective for modest-sized numbers, but can you tell what it does? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-22 19:18 -0700
    Re: This code is effective for modest-sized numbers, but can you tell what it does? "Graeme C." <graec58@gmail.com> - 2022-04-22 19:40 -0700
      Re: This code is effective for modest-sized numbers, but can you tell what it does? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-22 20:00 -0700
        Re: This code is effective for modest-sized numbers, but can you tell what it does? "Graeme C." <graec58@gmail.com> - 2022-04-23 04:21 -0700
  Re: This code is effective for modest-sized numbers, but can you tell what it does? Juha Nieminen <nospam@thanks.invalid> - 2022-04-25 05:48 +0000
    Re: This code is effective for modest-sized numbers, but can you tell what it does? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-04-25 05:27 -0700
      Re: This code is effective for modest-sized numbers, but can you tell what it does? Öö Tiib <ootiib@hot.ee> - 2022-04-25 05:40 -0700
        Re: This code is effective for modest-sized numbers, but can you tell what it does? Vir Campestris <vir.campestris@invalid.invalid> - 2022-04-25 16:48 +0100
          Re: This code is effective for modest-sized numbers, but can you tell what it does? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-04-30 03:51 -0700
            Re: This code is effective for modest-sized numbers, but can you tell what it does? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-30 08:28 -0700
              Re: This code is effective for modest-sized numbers, but can you tell what it does? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-30 10:30 -0700
              Re: This code is effective for modest-sized numbers, but can you tell what it does? Manfred <noname@add.invalid> - 2022-04-30 19:20 +0200
                Re: This code is effective for modest-sized numbers, but can you tell what it does? Manfred <noname@add.invalid> - 2022-04-30 23:20 +0200
                Re: This code is effective for modest-sized numbers, but can you tell what it does? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-30 10:40 -0700
              Re: This code is effective for modest-sized numbers, but can you tell what it does? Manfred <noname@add.invalid> - 2022-04-30 19:12 +0200
        Re: This code is effective for modest-sized numbers, but can you tell what it does? Juha Nieminen <nospam@thanks.invalid> - 2022-04-26 05:20 +0000
          Re: This code is effective for modest-sized numbers, but can you tell what it does? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-04-29 16:12 -0700
      Re: This code is effective for modest-sized numbers, but can you tell what it does? Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-25 15:44 +0300
        Re: This code is effective for modest-sized numbers, but can you tell what it does? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-05-10 07:18 -0700
          Re: This code is effective for modest-sized numbers, but can you tell what it does? scott@slp53.sl.home (Scott Lurndal) - 2022-05-10 14:34 +0000
            Re: This code is effective for modest-sized numbers, but can you tell what it does? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-05-24 05:43 -0700
          Re: This code is effective for modest-sized numbers, but can you tell what it does? Paavo Helde <eesnimi@osa.pri.ee> - 2022-05-10 20:34 +0300
            Re: This code is effective for modest-sized numbers, but can you tell what it does? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-06-04 07:57 -0700

csiph-web