Uhm, the kernel itself doesn't know anything about stderr.
With "it" I was referring to Perl, not the kernel...
What I find weird is that while Perl normally is printing warnings to whatever file descriptor is associated with the Perl file handle STDERR (typically 2, but not necessarily), it no longer seems to go via STDERR when it's closed (which would mean to just not print), but simply prints to fd 2 anyway — that's what I meant with "hard-wired".
Making the file descriptor variable would break many things, not in the least the expectation of users.
The file descriptor (associated with STDERR) is variable — as long as STDERR isn't closed:
#!/usr/bin/perl
close STDERR;
open AA, ">/tmp/myfd2" or die $!; # gets fd 2
open STDERR, ">/tmp/myfd3" or die $!; # gets fd 3
warn "Hello";
$ strace -eopen,write ./849816.pl
...
open("/tmp/myfd2", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 2
open("/tmp/myfd3", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
write(3, "Hello at ./849816.pl line 6.\n", 29) = 29
^