public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113522] std::swap cannot be called with explicit template argument std::array<int,3> Date: Thu, 25 Jan 2024 08:37:49 +0000 [thread overview] Message-ID: <bug-113522-4-DCRcOgRk7N@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113522-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113522 Jiang An <de34 at live dot cn> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |de34 at live dot cn --- Comment #4 from Jiang An <de34 at live dot cn> --- std::swap is not supposed to be called with explicitly specified template arguments. If the template arguments are not explicitly specified for std::swap, the correct overloads will be selected if you include currect headers, even when not all standard headers that declare std::swap overloads are included (the shape of overload set is unspecified in such cases). However, if you explicitly specify template arguments, there may be unintended (likely incorrect) overloads whose template arguments are no longer underdeduced to be selected. And then undesired implicit conversion can be trigged during overload resolution, which can make your program ill-formed. (In reply to Jonathan Wakely from comment #1) > This is silly code and there is no reason to support it. Hmm... currently it's specified in [algorithms.requirements] that > The well-formedness and behavior of a call to an algorithm with an explicitly-specified template argument list is unspecified, except where explicitly stated otherwise. (Added by P0896R4 and amended by LWG3419.) Should open an LWG issue to specify similar things for std::swap?
next prev parent reply other threads:[~2024-01-25 8:37 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-20 9:22 [Bug libstdc++/113522] New: " fchelnokov at gmail dot com 2024-01-20 9:27 ` [Bug libstdc++/113522] " redi at gcc dot gnu.org 2024-01-20 9:34 ` pinskia at gcc dot gnu.org 2024-01-20 9:35 ` pinskia at gcc dot gnu.org 2024-01-25 8:37 ` de34 at live dot cn [this message] 2024-01-25 9:38 ` redi at gcc dot gnu.org 2024-01-25 9:44 ` redi at gcc dot gnu.org 2024-01-25 9:48 ` pinskia at gcc dot gnu.org 2024-01-30 12:01 ` 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-113522-4-DCRcOgRk7N@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: linkBe 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).