develooper Front page | perl.perl5.porters | Postings from April 2012

[perl #16235] local($^W) does not work correctly

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
April 28, 2012 13:57
Subject:
[perl #16235] local($^W) does not work correctly
Message ID:
rt-3.6.HEAD-4610-1335646618-364.16235-15-0@perl.org
On Sat Apr 28 02:11:01 2012, Hugmeir wrote:
> On Tue Jul 15 23:16:04 2003, schwern wrote:
> > Confirmed in 5.8.0 and 5.8.1 RC2.
> 
> This is still present in 5.14.2 and blead, but a small update: The
> original bug report says that Solaris behaved differently,

Knowing how this is implemented, I think it was misdiagnosed.

> failing on
> the final die. Now it's the same same place as Linux/Windows, on
> 
> { local($^W) = $^W;
> die "BUG: warn is off5" unless $^W;
> }

Usually, local($foo) creates a new $foo in *foo{SCALAR}, copies the
magic to it, and then calls set-magic on it.  This allows a plain
local($^W); to work.

local($foo) = $foo works because the $foo on the RHS (which is executed
first) is the original $foo; i.e., a completely different scalar.

For magical variables things gang agley, because the local($^W) on the
LHS is a separate operator from assignment and sets $^W to undef befor
the assignment happens.  Since both $^W’s have magic that writes to the
same underlying structures, the assignment has no affect.

This is similar to bug #104118, but a little different; but I think it’s
the same code that would need adjustment.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=16235

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About