4 ms·
I think the truncate undefined behavior example is an example of OS behavior. On POSIX systems specifying a size greater than the current file size extends the
by wahern 4y ago
I think the truncate undefined behavior example is an example of OS behavior. On POSIX systems specifying a size greater than the current file size extends the file; it's well-defined[1]. So, presumably, Perl targets some other, non-POSIX operating systems where doing so is undefined.
[1] "If the file was previously shorter than length, its size is increased, and the extended area appears as if it were zero-filled." https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/t...
EDIT: Ah, it's VOS: "(VOS) Truncation to same-or-shorter lengths only." https://perldoc.perl.org/perlport#truncate https://perldoc.perl.org/perlport#truncate