Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For me there are 3 related but different points here:</p> <p><strong>A. <em>Deal</em> with the overflow</strong></p> <p>In fact, there are two parts here: <em>conversion</em> overflow and <em>addition</em> overflow. Even if you take <code>int16_t</code> as the input, there could still be an overflow at the <code>+=</code> stage, and you have to decide what to do with it (of course you can simply ignore it, but this is a choice too, with well-defined consequences).</p> <p><strong>B. <em>Inform</em> users about limitations</strong></p> <p>By choosing your (3) option - moving to the interface, you would inform the users about the first overflow but not about the second one. Also, it is <em>not</em> the only way to inform users. Sometimes a better way is to have "limitations" section in your documentation, to make it clear right away.</p> <p><strong>C. <em>Avoid</em> the warning</strong></p> <p>Once you have decided with (A), you can make the compiler happy by making the conversion according to what you decide.</p> <hr> <p>Your (1) and (3) is essentially the same thing, though people don't like warning suppression much. These options only answer <em>Avoid</em>, but not <em>Deal</em> nor <em>Inform</em>.</p> <p>(2) ignores the second overflow, and sends the first one to the user. So it does <em>Avoid</em> and partially <em>Inform</em>, ignoring a half of <em>Deal</em> and leaving the second half to the users.</p> <p>(4) is only about <em>Inform</em>, but has nothing to do with <em>Deal</em> and <em>Avoid</em>.</p> <hr> <p>What would I do? First I would decide on how to <em>Deal</em> with the overflow - depending on the application it can be quite different, i.e. it could be the standard overflow behavior or truncation to the maximum possible value. Then I would think on how to properly <em>Inform</em> my users - this depends on the way the docs are organized, if asserts/exceptions are acceptable etc. Finally, I would <em>Avoid</em> the warning according to that, by checking for overflow and acting according to the <em>Deal</em> strategy.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload