http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52167
Bug #: 52167 Summary: self-assignment should at least produce use-of-uninitialized warning Classification: Unclassified Product: gcc Version: 4.4.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: darko.vebe...@ung.si the following code gets compiled without any warnings (even with -Wall -Wextra): std::string foo(foo); and the resulting code segfaults (clang++ is also silent on this but the code throws std::length_error). i am aware that the example is ridiculous but it comes from a large real-life project and is possibly a result of negligent copy-paste operations, so at least issuing a warning would be nice. full example: #include <iostream> #include <string> using namespace std; int main() { const string foo(foo); cout << foo << endl; return 0; }