I was not able to register on the bug tracker, so I am posting a
couple feature requests here, I hope someone can repost them for me.
I would like to suggest -Wident=foo, such that it will warn each time
foo is encountered in the code. This is similar to [[deprecated]] but
it would allow the user to call this warning on code from third party
libraries unmodified.
Use cases: e.g., someone implemented "gets_widechar", so
"-Wident=gets_widechar".
Next suggestion is two C++ specific flags, "-Wextra-copy" and
"-felide-copies". "-Wextra-copy" warns when a soon expiring object is
copied instead of moved from. -felide-copies actually changes it to a
move instead of copy. Obviously this could cause bugs, so it should be
disabled by default even at -O2, probably -O3. The warning option
would give you a compromise in that it simply directs you to check
that this is what you meant to do. This warning should be suppressed
when copying from e.g., ints, of course (since it is the same as a
move.)
So for example:
extern void foo(std::string);
int main()
{
std::string s;
...
foo(s);
return 0;
}
With "-Wextra-copy" would emit a warning for the line "foo(s);"; and,
with -felide-copies, it would change the copy to a move.
Note: I heard glibc++ internally uses copy-on-write for strings, so
this specific example may not be a problem, but it was just an
example.
--
Thank you,
Ryan P. Nicholl
Freelance C++ Developer
(678)358-7765
r.p.nich...@gmail.com