The exemption of += from warning about an undef left operand is lost when the left operand has magic (specifically, get magic). This almost makes sense to me as a desirable behavior, but may just be an artifact of how the exemption is implemented (see below). Unfortunately tainting is managed with magic. The effect in this case could be construed as a bug.

The exemption, where it applies, it checks for undef before trying to get the numeric value, but in the presence of magic, the flags used to check for undef are unreliable before the magic get, and the magic get is coupled to getting the numeric value which is coupled to producing the undef warning. In 5.8.9 and above, versions of the routines to get integer values are available that don't process magic (Sv[UI]V_nomg), but not the routine to get a floating point value (SvNV) or the routine to get an integer value only to see if the number is in range (SvIV_please). If those were available, the procedure could be changed to: get magic, check if undef, if so, assume 0 without warning, otherwise get the numeric value without magic.


In reply to Re: Inconsistent warnings over undefined values by ysth
in thread Inconsistent warnings over undefined values by oxone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.