in reply to Inconsistent warnings over undefined values

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.

  • Comment on Re: Inconsistent warnings over undefined values

Replies are listed 'Best First'.
Re^2: Inconsistent warnings over undefined values
by oxone (Friar) on Jan 19, 2009 at 13:55 UTC
    Thanks ysth, from a 'user' point of view I'd consider it a bug (it certainly looks and smells like one), but it's good to know there's an explanation for this within the internals.