This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/62227] New: Templated move not elided


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]