This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52167] New: self-assignment should at least produce use-of-uninitialized warning
- From: "darko.veberic at ung dot si" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Feb 2012 08:24:18 +0000
- Subject: [Bug c++/52167] New: self-assignment should at least produce use-of-uninitialized warning
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: darko.veberic@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;
}