[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.
[Bug c++/64142] New: Add option, -felide-copies
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64142 Bug ID: 64142 Summary: Add option, -felide-copies 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 See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64141 Very simply, when you copy from a value, and the compiler can prove that this is the last use of the value before it goes out of scope, then the compiler should change this to a move operation.
[Bug c++/64142] Add option, -felide-copies
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64142 --- Comment #1 from Ryan Nicholl --- The option would be -felide-copies, incase the title needs to be changed later.
[Bug other/64143] New: Add option -felide-aliases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64143 Bug ID: 64143 Summary: Add option -felide-aliases Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: r.p.nicholl at gmail dot com I am suggesting to add the option -felide-aliases. For certian functions, perhaps those marked "hot", where the compiler can determine the widths of access of any pointers used, the compiler would check on entry, if certian pointers alias eachother or not, and then choose between multiple overloads of the function depending on if this pointer aliasing occured. So for example, when multiplying to matricies and putting the results in an index, if this optimization was enabled, on entry, it would check if the result and the other arguments overlap or not. Then it would jump to the correct function depending of the result of that check. It is also possible, during profiling, that the compiler may check which types of aliasing are more common, such as the case where the two inputs overlap commonly, but it is unlikey for the inputs to overlap with the output.