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++/64141] New: Add option, -Wextra-copy


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64141

            Bug ID: 64141
           Summary: Add option, -Wextra-copy
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: r.p.nicholl at gmail dot com

I am suggesting to add -Wextra-copy. When you copy from a value in local scope
which is not accessed again afterwards, then this warning is triggered.


So for example:

extern std::string bar();
extern void foo(std::string);

int main()
{
  std::string s = bar();
  foo(s);
  return 0;
}

This would cause a warning at the call to foo(s), because it could be replaced
with a move-call in most cases.


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