Doc. no. | N4096
Date: | 2014-07-05
Project: | Programming Language C++
Reply to: | Beman Dawes <bdawes at acm dot org>

# File System TS Closed Issues List (Revision R2)

Revised 2014-07-05 at 12:07:11 UTC

Reference ISO/IEC TS 18822

Also see:

- Table of Contents for all SG3 issues.
- Index by Section for all SG3 issues.
- Index by Status for all SG3 issues.
- Active Issues List
- Defect Reports List

This document contains only SG3 issues which have been closed by the File System Study Group as duplicates or not defects. That is, issues which have a status of Dup or NAD. See the Active Issues List active issues and more information. See the Defect Reports List for issues considered defects. The introductory material in that document also applies to this document.

## Revision History

- R2: 2014-07-04 SG-3 File System TS
  - Summary:
    - 6 open issues, down by 21.
    - 61 closed issues, up by 26.
    - 67 issues total, up by 5.
  - Details:
    - Added the following 5 New issues: 64, 65, 66, 67, 68.
    - Changed the following issue to NAD Future (from New): 54.
    - Changed the following issue to NAD Future (from Open): 11.
    - Changed the following 3 issues to WP (from Review): 25, 27, 57.
    - Changed the following 13 issues to WP (from New): 34, 35, 36, 37, 40, 41, 45, 48, 49, 56, 58, 60, 62.
    - Changed the following 3 issues to WP (from Open): 5, 22, 53.
    - Changed the following issue to NAD Editorial (from New): 59.
    - Changed the following 3 issues to NAD (from New): 38, 42, 61.
    - Changed the following issue to NAD (from Open): 4.

## Closed Issues

### 4. [PDTS] Need definition of dot and dot-dot

Section: X 4.14 [fs.def.parent] Status: NAD Submitter: CH-3 Opened: 2014-01-20 Last modified: 2014-07-04

View all issues with NAD status.

Discussion:

The concept of a parent directory for dot or dotdot exists, but the definition doesn't apply.

Suggested action:

Remove the paragraph. This concept does not apply to dot and dot-dot. Add a definition for dot and dot-dot.

[2014-02-07, Beman Dawes comments]

Suggest it is editorial and should be passed to the project editor.

[ 2014-02-11 Issaquah: Beman to provide wording for review next meeting. Also see related issue 5. ]

[22 May 2014 Beman Dawes comments:]

> I've now reviewed this issue carefully and believe it is NAD. "parent" is used in four places in the WP, and so deserves a definition. The current definition is copied word-for-word and in its entirety from the POSIX definition. I believe strongly that the File System TS needs to stay in alignment with POSIX on this matter, and that the best way to do that is simply to use the POSIX wording.

[17 Jun 2014 Rapperswil LWG closes as NAD. No concensus for change.]

Proposed resolution:

### 10. [PDTS] Apparently inconsistent return types from several functions

Section: X 6 [fs.filesystem.synopsis] Status: NAD Submitter: FI-4 Opened: 2014-01-20 Last modified: 2014-06-27

View all other issues in 6 [fs.filesystem.synopsis].

View all issues with NAD status.

Discussion:

It is unclear why `copy`, `copy_file` and `copy_symlink` have different return types, and why the attribute-version of `create_directory` has a different return type than the `create_directory` that takes no attributes. The status/error reporting in these functions seems inconsistent.

Resolution:

Make the status/error reporting consistent or add a note explaining why it's different.

[ 2014-02-11 Issaquah: NAD. LWG/SG-3 reviewed each function and return type, and found that since they have different functionality different return types are warranted. `create_directory` has an inconsistent return type between the synopsis and the description. This has subsequently been corrected editorially. ]

Proposed resolution:

### 11. [PDTS] Lack of `relative()` operation function

Section: X 6 & 15 Status: NAD Future Submitter: GB-1 Opened: 2014-01-20 Last modified: 2014-07-04

View all issues with NAD Future status.

Discussion:

There is no `relative()` operation, to complement both `absolute()` and `canonical()`

The TS introduces relative paths.

- They are defined in section 4.18 relative path [fs.def.relative-path]

- A decomposition method `relative_path()` is described in section 8.4.9 path decomposition [path.decompose]

- Two query methods to determine if a path either `has_relative_path()` or `is_relative()` described in 8.4.10 path query [path.query]

However there is no way to create a relative path as a path relative to another. Methods are provided to create absolute and canonical paths.

In section 15.1 Absolute [fs.op.absolute]:

path absolute(const path& p, const path& base=current_path());

and in section 15.2 Canonical [fs.op.canonical]

path canonical(const path& p, const path& base = current_path());

path canonical(const path& p, error_code& ec);

path canonical(const path& p, const path& base, error_code& ec);

By providing a operations to achieve absolute and canonical paths there is no impediment to providing a similar operation relative() that attempts to return a new path relative to some base path.

For example:

path relative(const path& p, const path& to = current_path());

path relative(const path& p, error_code& ec);

path relative(const path& p, const path& to, error_code& ec);

This would return a path, if possible, that is relative to to. The implementation can make use of absolute() and canonical() to determine the relative path, if it exists.

The File System TS is based on the ​boost::filesystem library and it too suffers from this anomaly. There are open tickets for this in ​Boost Trac:

- ​#5897 Make path relative function

- ​#1976 Inverse function for complete

and it is the subject of several posts on StackOverflow for example:

- ​http://stackoverflow.com/questions/10167382/boostfilesystem-get-relative-path

- ​http://stackoverflow.com/questions/5772992/get-relative-path-from-two-absolute-paths

Other languages typically provide a similar function. For example python provides:

os.path.relpath(path[, start])

Return a relative filepath to path either from the current directory or from an optional start directory. This is a path computation: the filesystem is not accessed to confirm the existence or nature of path or start. start defaults to os.curdir.

[2014-02-07, Beman Dawes comments]

A `relative()` function is useful and much requested. I've seen such a function provided by users and have written it myself in app code. It is one of those things I've been meaning to do for years, and have just never gotten around to.

That said, my mild preference is to treat this as "NAD, Future" for File System TS1, but treat it as a priority for TS2.

[ 2014-02-11 Issaquah ]

The LWG/SG-3 voted strongly in favor of adding this functionality, and doing so in this TS. That implies quite a bit of work before the next meeting to validate that the proposed interface works as desired for various platforms. There was general agreement not to hold FS STS1 if this functionality isn't ready when the rest of the TS is ready.

[2014-05-19 Beman Dawes supplied wording. The design benefited from discussions with Jamie Allsop, who was the source of the original NB comment. Thanks to Bjorn Reese for corrections and suggestions. Although there was also discussion and experimentation with additional relative functions that took into account symlinks and normalization, these are not proposed here since even the proponents of such functions were unsure of appropriate semantics.]

[17 Jun 2014 Rapperswil LWG closes as NAD, Future. Although there is strong concensus for eventually providing both lexical and existence based flavors of relative() functionality, discussion of the many possible design choices led to the conclusion that more research and actual user experience is necessary before moving forward. Interested parties should submit papers.]

Original proposed resolution:

1. Modify header `<filesystem>` synopsis, 6 [fs.filesystem.synopsis], by adding the operational functions after `canonical`:

   >     path relative(const path& p, const path& to = current_path());
   >     path relative(const path& p, error_code& ec);
   >     path relative(const path& p, const path& to, error_code& ec);

2. Insert the section:

   > 15.3 Relative [fs.op.relative]

   >     path relative(const path& p, const path& to = current_path());
   >     path relative(const path& p, error_code& ec);
   >     path relative(const path& p, const path& to, error_code& ec);

   > > Overview: Return a relative path of p to the current directory or from an optional to path.

   > > Returns: A relative path such that `canonical(to)/relative(p,to) == canonical(p)`, otherwise `path()`. If `canonical(to) == canonical(p)` the path `path(".")` is returned. For the overload without a `to` argument, `to` is `current_path()`. Signatures with argument `ec` return `path()` if an error occurs.

   > > Throws: As specified in Error reporting.

   > > Remarks: `!exists(p) or !exists(to) or !is_directory(to)` is an error.

   and bump all following sections up by 0.1. Update the contents and any cross-references accordingly.

Question: Should Returns be specified in terms of equivalence? For example: `equivalent( canonical(to)/relative(p,to), canonical(p) )`

Question: Should `canonical(to) == canonical(p)` return `path(".")` or `path()`? Why?

Question: Should `to` be spelled `start`?

Proposed resolution:

To 6 Header <experimental/filesystem> synopsis [fs.filesystem.synopsis], add:

>     path lexically_relative(const path& p, const path& base);

At the end of 8.6 path non-member functions [path.non-member], add

> #### 8.6.3 `path` lexically_relative function [path.lexically.relative]

>     path lexically_relative(const path& p, const path& base);

> > Creates a path from the trailing elements of `p` that are lexically relative to `base`, which must be a prefix of `p`.

> > Effects: If the number of elements in [`p.begin(), p.end()` ) is less than or equal to the number of elements in [`base.begin(), base.end()` ), or if any element in [`base.begin(), base.end()`) is not equal to the corresponding element in [`p.begin(), p.end()`), throw an exception of type `filesystem_error`.

> > Remarks: Equality or inequality are determined by `path::operator==` or `path::operator!=` respectively.

> > Returns: An object of class `path` containing the first element of `p` that does not have a corresponding element in `base,` followed by the subsequent elements of `p` appended as if by `path::operator/=`.

> > Throws: `filesystem_error`.

> > [Note: Behavior is determined by the lexical value of the elements of `p` and `base` - the external file system is not accessed. The case where an element of `base` is not equal to corresponding element of `p` is treated as an error to avoid returning an incorrect result in the event of symlinks. --end note]

> A possible implementation would be:

> >     auto mm = std::mismatch( p.begin(), p.end(), base.begin(), base.end());
> >     if (mm.first == p.end() || mm.second != base.end())
> >     {
> >     throw filesystem_error(
> >     "p does not begin with base, so can not be made relative to base",
> >     p, base,
> >     error_code(errc::invalid_argument, generic_category()));
> >     }
> >     path tmp(*mm.first++);
> >     for (; mm.first != p.end(); ++mm.first)
> >     tmp /= *mm.first;
> >     return tmp;

### 12. [PDTS] `uintmax_t` too small for large file sizes

Section: X [fs.filesystem.synopsis], [fs.op.file_size] Status: NAD Future Submitter: CH-8 Opened: 2014-01-20 Last modified: 2014-06-27

View all issues with NAD Future status.

Discussion:

`uintmax_t` is specified to hold at least 64 bit. This is not enough for sizes beyond 4 [sic] exabytes.

Specify whether an implementation must provide a `uintmax_t` that can hold the maximum possible space and file size values.

[2014-02-06: Jeffery Yasskin points out 64-bits unsigned actually has a maximum value of "16 exabytes, not 4"]

[2014-02-07: Beman Dawes suggests: This should be NAD. Such ultra-large files are the province of enterprise-wide filesystems such as requested by IBM and others for a follow-on SG3 TS. That would be the best vehicle to address this concern IMO.]

[ 2014-02-11 Issaquah: NAD Future. ]

Proposed resolution:

### 13. [PDTS] Missing actual error conditions thrown

Section: X 7 [fs.err.report] etc. Status: NAD Submitter: CH 9 Opened: 2014-01-20 Last modified: 2014-06-27

View all issues with NAD status.

Discussion:

The specification of the actual error conditions for the functions that specify Throws: As specified in Error reporting. is missing.

Add those specifications.

[2014-02-07, Beman Dawes comments]

The actual error codes, and thus the error conditions, are determined by the operating system, and thus operating system dependent.

[2014-02-11 Issaquah]

There is no consensus for a change. LWG/SG3 requested a separate issue be opened to clarify 7 [fs.err.report]. See issue 55.

Proposed resolution:

### 17. [PDTS] `path` member `swap()` unnecessary

Section: X 8.4.5 [path.modifiers] Status: NAD Submitter: CH-12 Opened: 2014-01-20 Last modified: 2014-06-27

View all issues with NAD status.

Discussion:

As we have move semantics, member `swap` functions shouldn't be necessary any more.

[2014-02-12 LWG/SG-3 Issaquah ]

No consensus for change. STL pointed out that swap should be noexcept and will submit a separate issue.

Proposed resolution:

Remove `swap()`.

### 23. [PDTS] Request for `create_regular_file()` and/or `touch()`

Section: X 15 Status: NAD Submitter: CH-14 Opened: 2014-01-20 Last modified: 2014-05-24

View all issues with NAD status.

Discussion:

Since `create_symlink()`, `create_hardlink()`, and `create_directory()` exist, there's no reason not to have a `create_regular_file()` function.

Consider adding a function `create_regular_file()` with the behaviour of the POSIX `touch` command.

[Beman comments]

`create_regular_file()` and `touch()` should be different functions since their behavior would differ if the file already exists; touch() updates the last write date.

I have often wanted `create_regular_file()` but never got around to adding it.

While `touch` is quite useful from the command line, I'm less sure of its usefulness as a library function. It is trivial for a user to implement.

Whether or not it is appropriate to add operational functions this late in the PDTS process is questionable.

[2014-02-13 LWG/SG-3 Issaquah: No consensus for change at this time.]

Proposed resolution:

### 26. [PDTS] Equivalence is a volatile property

Section: X 15.13 [fs.op.equivalent] Status: NAD Submitter: CH-16 Opened: 2014-01-20 Last modified: 2014-05-24

View all issues with NAD status.

Discussion:

Equivalence is a volatile property.

Consider adding a note that equivalence cannot be determined race-free.

[2014-02-13 LWG/SG-3 Issaquah: No consensus for change. Section 2.1 description of races is sufficient.]

Proposed resolution:

### 28. [PDTS] Possible `last_write_time()` postcondition?

Section: X 15.25 [fs.op.last_write_time] Status: NAD Submitter: GB-15 Opened: 2014-01-20 Last modified: 2014-05-24

View all other issues in 15.25 [fs.op.last_write_time].

View all issues with NAD status.

Discussion:

The constraint on `last_write_time` is too weak: It is noted that the postcondition of `last_write_time(p) == new_time` is not specified since it might not hold for file systems with coarse time granularity.

However, might it be possible to have a postcondition that `last_write_time(p) <= new_time` ?

Add postcondition: `last_write_time(p) <= new_time`

[2014-02-09, Beman Dawes comments:]

That assumes the file system rounds down. We don't know which direction a file system rounds. Nice try, but this one looks NAD to me.

[2014-02-13 LWG/SG-3 Issaquah: No consensus for change.]

Proposed resolution:

### 30. [PDTS] `remove()` must avoid race

Section: X 15.28 [fs.op.remove] Status: NAD Submitter: CH-17 Opened: 2014-01-20 Last modified: 2014-05-24

View all issues with NAD status.

Discussion:

The specification can be read to require the existence test. As this introduces a race, the existence test must not happen.

Change to: "Effects: `p` is removed as if by POSIX `remove()`."

[2014-02-13 LWG/SG-3 Issaquah: Insufficient consensus for change. Vote for NAD: 9 0 0 2 1.]

Proposed resolution:

This wording is relative to SG3 working draft.

1. Change X 15.28 [fs.op.remove] as indicated:

   > Effects: If `exists(symlink_status(p,ec))`, it `p` is removed as if by POSIX `remove()`.

### 31. [PDTS] POSIX guarantees atomicity for `rename()`

Section: X 15.30 [fs.op.rename] Status: NAD Submitter: CH-18 Opened: 2014-01-20 Last modified: 2014-06-27

View all issues with NAD status.

Discussion:

POSIX guarantees some kind of atomicity for `rename()`.

Clarify that POSIX' `rename()` guarantee "If the `rename()` function fails for any reason other than [EIO], any file named by new shall be unaffected." holds for C++ as well.

[2014-02-10 Beman Dawes]

Section 2.1, POSIX conformance, [fs.conform.9945] specifies the POSIX conformance requirements for TS implementations in carefully crafted and specific detail. Repeating a portion of the POSIX standard's specification for a particular TS function would do great harm as it would bring into question all of the portions of the POSIX specification for the function that were not repeated.

Furthermore, all the caveats and other details of the 2.1 specification would have to be analyzed and possibly appended; it ties the hands of implementors if they are not given latitude to deviate as needed when working with non-POSIX operating systems.

I strongly recommend NAD for this issue.

[2014-02-13 LWG/SG-3 Issaquah: No consensus for change.]

Proposed resolution:

### 38. [PDTS] Make certain functions `noexcept` and drop `error_code` version

Section: X 12.3 [directory_entry.obs], X 15.12 [fs.op.exists], X 15.16 [fs.op.is_block_file], X 15.17 [fs.op.is_char_file], X 15.18 [fs.op.is_directory], X 15.19 [fs.op.is_empty], X 15.20 [fs.op.is_fifo], X 15.21 [fs.op.is_other], X 15.22 [fs.op.is_regular_file], X 15.23 [fs.op.is_socket], X 15.24 [fs.op.is_symlink], X 15.33 [fs.op.status], X 15.35 [fs.op.symlink_status], X 15.38 [fs.op.unique_path] Status: NAD Submitter: P.J. Plauger Opened: 2014-01-30 Last modified: 2014-07-04

View all other issues in 12.3 [directory_entry.obs].

View all issues with NAD status.

Discussion:

`exists(const path&)` should be `noexcept` (drop `error_code` version).
`is_*(const path&)` should be `noexcept` (drop `error_code` version).
`status(const path&)` should be `noexcept` (drop `error_code` version).
`symlink_status(const path&)` should be `noexcept` (drop `error_code` version).
`file_status::status()` should be `noexcept` (drop `error_code` version).
`file_status::symlink_status()` should be `noexcept` (drop `error_code` version).
`unique_path(const path&)` should be `noexcept` (drop `error_code` version).

[2014-02-08: Daniel comments]

`unique_path(const path&)` cannot be declared as `noexcept`, because it returns an object during whose construction a memory allocation request may fail, see the rationale provided in 37.

`exists(const path&)` and the `is_*(const path&)` functions cannot be `noexcept`, because they are specified in terms of `status(const path&)`, which again may throw an exception, which is explicitly described in the Effects (`filesystem_error`), because the non-throwing function (`status(const path&, error_code&)`) may fail to satisfy the request.

`symlink_status(const path&)` may throw an exception for similar reasons that `status(const path&)` could fail.

The reference to `file_status::status()/symlink_status()` looks like a typo to me (there are no such functions in `file_status`), presumably `directory_entry::status()/symlink_status()` was meant. In this case I see no reason how these could be marked as `noexcept`, because these functions all may fail and may throw an exception.

Based on this interpretation of the issue discussion I recommend to resolve this issue as NAD.

[Beman Dawes 2014-02-27]

Issues 37, 38, 41, and 49 are concerned with signatures which should or should not be `noexcept`. I will provide unified proposed wording for these issues, possibly in a separate paper.

[17 Jun 2014 Rapperswil LWG closes as NAD. Working paper correct as written.]

Proposed resolution:

### 39. [PDTS] `permissions()` is missing from synopsis

Section: X 6 [fs.filesystem.synopsis] Status: NAD Editorial Submitter: P.J. Plauger Opened: 2014-01-30 Last modified: 2014-06-27

View all issues with NAD Editorial status.

Discussion:

permissions function is missing from the summary list.

Proposed resolution:

[2014-02-07: Beman Dawes comments: Fixed as Editorial.]

### 42. [PDTS] `class path` should have defaulted constructors/destructor/assignments.

Section: X 8 [class.path] Status: NAD Submitter: P.J. Plauger Opened: 2014-01-30 Last modified: 2014-07-04

View all other issues in 8 [class.path].

View all issues with NAD status.

Discussion:

`class path` should have defaulted constructors/destructor/assignments.

[2014-02-26 Beman Dawes comments]

Suggest NAD. Earlier versions did have defaulted constructors/destructor/assignments, but they were removed at the request of Alberto Ganesh Barbati (c++std-filesys January 8, 2013):

> Speaking of `=default`, we have to be careful not over-constrain the specification. I mean, if we just specify the intended meaning of those function with proper wording, the implementation is allowed to use `=default` in case it provides an equivalent behaviour, but if we put `=default` in the specification, the implementation is required to use it. However, we have to remember that "for exposition only" data members may not be an exhaustive list and that 17.5.2.3/2 allows implementations to provide an equivalent behaviour using different members for which "default" construction/copy/assignment may not be appropriate.

> `=default` is what we want for tuple, atomics, etc. It might be appropriate for simple types like file_status, but, for more complex types like `path` itself, I'd remove it and add proper wording.

[17 Jun 2014 Rapperswil LWG closes as NAD. Ganesh's analysis is correct. WP correct as written.]

Proposed resolution:

### 43. [PDTS] `path::compare(const string&)` should be `path::compare(const string_type&)`

Section: X 8 [class.path] Status: Dup Submitter: P.J. Plauger Opened: 2014-01-30 Last modified: 2014-06-27

View all other issues in 8 [class.path].

View all issues with Dup status.

Discussion:

`path::compare(const string&)` should be `path::compare(const string_type&)`.

[2014-02-08 Daniel comments]

This issue is a duplicate of 50. The suggested wording of that issue would resolve this issue here as well.

[2014-02-13 LWG/SG-3 Issaquah: Agrees with Daniel.]

Proposed resolution:

### 46. [PDTS] Do we really need `generic*`?

Section: X 8.4.7 [path.generic.obs] Status: NAD Submitter: P.J. Plauger Opened: 2014-01-30 Last modified: 2014-05-24

View all issues with NAD status.

Discussion:

Do we really need `generic*`?

[2014-02-08 Daniel comments]

These functions should exist for more than one reason.

First, the generic pathname format is a well-defined concept for the `path` specification and defining just a single way into a `path` but not out of it looks like an incomplete design.

More importantly, the existence of these functions have demonstrated to be quite useful in practice, because the generic pathname format concept is popular for many tools such as `maven` or the some configuration files for the Eclipse IDE do understand this syntax uniformly on all platforms and it allows to generate or modify such files using C++ code based on `filesystem::path`. The practical problem of the non-portable root-names doesn't matter in such contexts, because the serialized path names are in general relative names or depend on initial parts that are determined by properties or environment variables.

In other words: I'm recommending NAD for this issue.

[2014-02-13 LWG/SG-3 Issaquah: Withdrawn by submitter.]

Proposed resolution:

### 51. [PDTS] `directory_iterator`, `recursive_directory_iterator`, `pointer`/`reference` typedefs wrong

Section: X 13 [class.directory_iterator], X 14 [class.rec.dir.itr] Status: Dup Submitter: Stephan T. Lavavej Opened: 2014-02-03 Last modified: 2014-06-27

View all other issues in 13 [class.directory_iterator].

View all issues with Dup status.

Discussion:

`directory_iterator` and `recursive_directory_iterator` are constant iterators, but their `pointer`/`reference` typedefs are wrong (`std::iterator` defaults to providing modifiable ones).

[2014-02-08 Daniel comments]

I noticed the same problem when trying to resolve 52. The currently suggested wording for that issue should fix the here mentioned problem as well.

I recommend to solve this issue as "Resolved by the proposed wording for 52".

[2014-02-13 LWG/SG-3 Issaquah: Daniel's resolution accepted.]

Proposed resolution:

### 54. [PDTS] Concerns with security and testability

Section: X all Status: NAD Future Submitter: Google Opened: 2014-01-20 Last modified: 2014-07-04

View all issues with NAD Future status.

Discussion:

We have two primary concerns with the interface as specified:

(a) its interface repeats the mistake of V7 Unix in 1979 by exposing access checking (and similarly file creation) independently from opening and mutating the file, and

(b) it provides no realistic means of testing a software library which uses the standard interface for accessing the filesystem under fault scenarios.

Due to the extent of (a), TOCTTOU [1] security vulnerabilities are guaranteed, if not during access checking[2], during other common operations such as temporary file creation[3].

Due to (b) it is impossible to portably test libraries using the proposed interface against critical correctness and security edge cases.

[1]: TOCTTOU: Time-of-check-to-time-of-use. Operating system integrity in OS/VS2

[2]: Fixing Races for Fun and Profit: How to use access(2)

[3]: Checking for Race Conditions in File Accesses

[Beman Dawes: 10 Feb 2014: Suggested response: NAD, Future]

> We share your concerns and look forward to receiving specific proposals to address them. Whether they will addressed by a revision of TS 18822 or a new TS will be decided as proposals progress through the committee process. See How To Submit a Proposal.

[17 Jun 2014 Rapperswil LWG agrees NAD, Future with rationale as stated above.]

Proposed resolution:

### 59. [PDTS] Invalid expressions for bitmask types

Section: X 10 [fs.enum] Status: NAD Editorial Submitter: Daniel Krügler Opened: 2014-03-01 Last modified: 2014-07-04

View all issues with NAD Editorial status.

Discussion:

`copy_options` is declared as `enum class` type that is a bismask type, but the specification repeatedly uses expressions that are invalid for scoped enums, such as:

> `!(options)`

because there is no contextual conversion to bool, not even the || operator in:

> `((options & copy_options::recursive) || !(options))`

Affected are basically all formulations in the form:

> "if `options & copy_options::create_symlinks` [..]"

because all rely on contextual conversion to bool. The only other specifically mention scoped enumeration in the standard that is also a bit mask type is the `launch` enum and the wording there always uses forms such as:

> "if `policy & launch::deferred` is non-zero"

which better acknowledges the fact that the obtained values does not necessarily undergo an implicit conversion.

I think the current wording in the file system spec. must be changed, especially for invalid expressions of the form:

> `((options & copy_options::recursive) || !(options))`

A similar problem arises in the usage of the bitmask type `perms` for the expression:

> `((prms & add_perms) && (prms & remove_perms))`

The only way how to describe this with a scoped enum is the lengthier form

> `((prms & perms::add_perms) != perms::none && (prms & perms::remove_perms) != perms::none)`

thus fixing several problems:

- The unscoped access to `add_perms` and `remove_perms` is incorrect
- The result of & is the bitmask type again and cannot be implicitly converted to bool

[20 May 2014 Beman Dawes provides proposed wording. Fixing invalid C++ is editorial, but treating this as an issue ensures more people review the proposed changes.]

[17 Jun 2014 Rapperswil LWG requests issue be handled as editorial.]

Proposed resolution:

Change 15.3 Copy [fs.op.copy]:

> > Before the first use of `f` and `t`:

> > - If `(options & copy_options::create_symlinks) != copy_options::none || (options & copy_options::skip_symlinks) != copy_options::none`, then `auto f = symlink_status(from)` and if needed `auto t = symlink_status(to)`.
> > - Otherwise, `auto f = status(from)` and if needed `auto t = status(to)` .

> > Report an error as specified in Error reporting (7) if:

> > - `!exists(f)`, or
> > - `equivalent(from, to)`, or
> > - `is_other(f) || is_other(t)`, or
> > - `is_directory(f) && is_regular_file(t)`.

> > If `is_symlink(f)`, then:

> > - If `(options & copy_options::skip_symlinks) != copy_options::none`, then return.
> > - Otherwise if `!exists(t)`, then `copy_symlink(from, to, options)` .
> > - Otherwise report an error as specified in Error reporting (7).

> > Otherwise if `is_regular_file(f)`, then:

> > - If `(options & copy_options::directories_only) != copy_options::none`, then return.
> > - Otherwise if `(options & copy_options::create_symlinks ) != copy_options::none`, then create a symbolic link to the source file.
> > - Otherwise if `(options & copy_options::create_hard_links) != copy_options::none`, then create a hard link to the source file.
> > - Otherwise if `is_directory(t)`, then `copy_file(from, to/from.filename(), options)` .
> > - Otherwise, `copy_file(from, to, options)`.

> > Otherwise if `is_directory(f) && ((options & copy_options::recursive) != copy_options::none || !(options == copy_options::none))` then:

> > - If `!exists(t)`, then `create_directory(to, from)` .
> > - Then, iterate over the files in `from`, as if by `for (directory_entry& x : directory_iterator(from))` , and for each iteration `copy(x.path(), to/x.path().filename(), options | copy_options::unspecified)` .

Change 15.4 Copy file [fs.op.copy_file]:

> If `exists(to) &&` `!(options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none` report a file already exists error as specified in Error reporting (7).

> If `!exists(to) || (options & copy_options::overwrite_existing) != copy_options::none || ((options & copy_options::update_existing) != copy_options::none && last_write_time(from) > last_write_time(to)) || !(options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none` copy the contents and attributes of the file `from` resolves to the file `to` resolves to.

Change 15.26 Permissions [fs.op.permissions]:

> Requires: `!((prms & perms::add_perms) != perms::none && (prms & perms::remove_perms) != perms::none)`.

### 61. Surprising `equivalent()` behavior if neither file exists

Section: X 6 [fs.filesystem.synopsis] Status: NAD Submitter: Beman Dawes Opened: 2014-04-12 Last modified: 2014-07-04

View all other issues in 6 [fs.filesystem.synopsis].

View all issues with NAD status.

Discussion:

`bool equivalent(const path& p1, const path& p2);` has always thrown a exception if neither file exists, with rationale that if they don't exist, it isn't possible to tell if two paths are equivalent. Dave Abrahams has reported that this is counter-intuitive and hard to teach.

An alternative if neither path exists would be to return true if they are lexically equal (operator==), otherwise return false.

This was not a national body comment, and Dave is the only one I can recall ever complaining about the current behavior. On the other hand, any complaint from Dave deserves serious consideration.

[17 Jun 2014 Rapperswil LWG considers this NAD. Mixing lexical and existence based behavior is not desirable.]

Proposed resolution: