public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thomas.allen at intel dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/106932] Incorrect behavior of std::filesystem::copy() with overwrite_existing or update_existing options
Date: Tue, 13 Sep 2022 21:43:28 +0000 [thread overview]
Message-ID: <bug-106932-4-jULOhafVqk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106932-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106932
--- Comment #6 from Tom Allen <thomas.allen at intel dot com> ---
(In reply to Jonathan Wakely from comment #5)
> (In reply to Tom Allen from comment #4)
> > If this is the case, then when I have subdirectories which I explicitly do
> > not want to copy, but files at the same level in the source directory which
> > I do want to overwrite in their destinations, there is no way to perform the
> > operation unless I manually iterate and check file types, then call
> > copy_file().
>
> I don't think that's quite true. You can still use filesystem::copy, you
> just need to use copy_options specific to the file type. So iterate over the
> directory contents and for directories, call filesystem::copy with no
> arguments, and for files, call filesystem::copy with update_existing /
> overwrite_existing.
>
> > That seems like a strange asymmetry compared to the recursive
> > call.
>
> For a recursive call, passing copy_options that only make sense for files is
> useful, because there could be files somewhere in a sub-dir that you want to
> copy. Passing those when copying just a directory, without recursing, isn't
> useful.
>
> For a shallow, non-recursive copy, I think it makes sense that you would
> have to call copy for each file individually, and if you're already doing
> that, it's not such a stretch to use arguments specific to the file type.
>
> In any case, that's what the standard says, so it's not a GCC bug.
>
> If you think this is a defect in the standard then report it to the
> committee instead:
> https://cplusplus.github.io/LWG/lwg-active.html#submit_issue
In this case, would it be possible to add a warning to the compiler for this
usage? Even with -Wall -Wextra it's silent, and since it functions as a no-op,
it's somewhat confusing to track down.
next prev parent reply other threads:[~2022-09-13 21:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-13 18:41 [Bug libstdc++/106932] New: " thomas.allen at intel dot com
2022-09-13 18:45 ` [Bug libstdc++/106932] " thomas.allen at intel dot com
2022-09-13 19:40 ` redi at gcc dot gnu.org
2022-09-13 19:43 ` redi at gcc dot gnu.org
2022-09-13 20:34 ` thomas.allen at intel dot com
2022-09-13 20:59 ` redi at gcc dot gnu.org
2022-09-13 21:43 ` thomas.allen at intel dot com [this message]
2022-09-14 9:17 ` redi at gcc dot gnu.org
2022-09-16 16:41 ` rs2740 at gmail dot com
2022-09-16 20:10 ` [Bug libstdc++/106932] [DR 3057] " redi at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-106932-4-jULOhafVqk@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).