Title
resize_file has impossible postcondition
Status
c++20
Section
[fs.op.resize.file]
Submitter
Richard Smith

Created on 2016-11-07.00:00:00 last changed 44 months ago

Messages

Date: 2018-03-18.16:03:30

Proposed resolution:

This wording is relative to N4713.

[Drafting note: I considered a slightly more verbose form: "Causes the size in bytes of the file p resolves to, as determined by file_size ([fs.op.file_size]), to be equal to new_size, as if by POSIX truncate." but I don't think it's an improvement. The intent of the proposed wording is that if either file_size(p) or truncate(p.c_str()) would fail then an error occurs, but no call to file_size is required, and file system races might change the size before any such call does occur.]

  1. Modify [fs.op.resize_file] as indicated:

    void resize_file(const path& p, uintmax_t new_size);
    void resize_file(const path& p, uintmax_t new_size, error_code& ec) noexcept;
    

    -1- Postconditions: file_size(p) == new_sizeEffects: Causes the size that would be returned by file_size(p) to be equal to new_size, as if by POSIX truncate.

    -2- Throws: As specified in [fs.err.report].

    -3- Remarks: Achieves its postconditions as if by POSIX truncate().

Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2018-01-26.00:00:00

[ 2018-1-26 issues processing telecon ]

Status to 'Tentatively Ready'

Date: 2018-01-15.00:00:00

[ 2018-01-16, Jonathan provides wording ]

Date: 2017-02-02.00:41:18

[ Issues Telecon 16-Dec-2016 ]

Priority 3

Date: 2016-11-07.00:00:00

resize_file has this postcondition (after resolving late comment 42, see P0489R0):

Postcondition: file_size(p) == new_size.

This is impossible for an implementation to satisfy, due to the possibility of file system races. This is not actually a postcondition; rather, it is an effect that need no longer hold when the function returns.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9725
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2018-01-28 19:43:07adminsetmessages: + msg9649
2018-01-28 19:43:07adminsetstatus: new -> ready
2018-01-20 15:28:42adminsetmessages: + msg9612
2018-01-20 15:28:42adminsetmessages: + msg9611
2016-12-16 20:56:38adminsetmessages: + msg8747
2016-11-07 00:00:00admincreate