public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/62227] New: Templated move not elided @ 2014-08-22 11:37 roman.perepelitsa at gmail dot com 2014-08-23 23:12 ` [Bug c++/62227] " redi at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: roman.perepelitsa at gmail dot com @ 2014-08-22 11:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62227 Bug ID: 62227 Summary: Templated move not elided Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: roman.perepelitsa at gmail dot com #include <stdio.h> struct S { S(int) {} S(const S&) = default; // (1) template <class = void> // (2) S(S&& other) { puts("move"); } }; int main() { S s = 42; (void)s; } This program unexpectedly prints "move". The expected output is empty (move is elided). The program prints nothing (as expected) if any of the following is done: - Line (1) is removed. - Line (2) is removed. - The program is compiled with clang. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/62227] Templated move not elided 2014-08-22 11:37 [Bug c++/62227] New: Templated move not elided roman.perepelitsa at gmail dot com @ 2014-08-23 23:12 ` redi at gcc dot gnu.org 2014-08-24 23:20 ` redi at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2014-08-23 23:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62227 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- A template cannot be a move constructor and so it is not legal to elide it. Removing line (1) means there is a move constructor implicitly declared, which will be used and can be elided. Removing line (2) means there is a move constructor, which will be used and elided. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/62227] Templated move not elided 2014-08-22 11:37 [Bug c++/62227] New: Templated move not elided roman.perepelitsa at gmail dot com 2014-08-23 23:12 ` [Bug c++/62227] " redi at gcc dot gnu.org @ 2014-08-24 23:20 ` redi at gcc dot gnu.org 2014-08-24 23:24 ` redi at gcc dot gnu.org 2021-08-23 0:28 ` [Bug c++/62227] [DR535] " pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2014-08-24 23:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62227 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- C++11 says "When certain criteria are met, an implementation is allowed to omit the copy/move construction of a class object, even if the copy/move constructor..." which only applies to copy constructors or move constructors. But the current draft says "even if the constructor selected for the copy/move operation" So it does seem that elision is now allowed when the relevant constructor is a template. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/62227] Templated move not elided 2014-08-22 11:37 [Bug c++/62227] New: Templated move not elided roman.perepelitsa at gmail dot com 2014-08-23 23:12 ` [Bug c++/62227] " redi at gcc dot gnu.org 2014-08-24 23:20 ` redi at gcc dot gnu.org @ 2014-08-24 23:24 ` redi at gcc dot gnu.org 2021-08-23 0:28 ` [Bug c++/62227] [DR535] " pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2014-08-24 23:24 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62227 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#535 changed that wording ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/62227] [DR535] Templated move not elided 2014-08-22 11:37 [Bug c++/62227] New: Templated move not elided roman.perepelitsa at gmail dot com ` (2 preceding siblings ...) 2014-08-24 23:24 ` redi at gcc dot gnu.org @ 2021-08-23 0:28 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-08-23 0:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62227 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- C++17 and C++20 modes no longer print move since GCC 7. Most likely due to the patches to implement p0135. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0135r1.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-23 0:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-08-22 11:37 [Bug c++/62227] New: Templated move not elided roman.perepelitsa at gmail dot com 2014-08-23 23:12 ` [Bug c++/62227] " redi at gcc dot gnu.org 2014-08-24 23:20 ` redi at gcc dot gnu.org 2014-08-24 23:24 ` redi at gcc dot gnu.org 2021-08-23 0:28 ` [Bug c++/62227] [DR535] " pinskia at gcc dot gnu.org
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).