[Bug c++/49481] New: Warn about string literal + character
veksler at il dot ibm.com
gcc-bugzilla@gcc.gnu.org
Tue Jun 21 05:50:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49481
Summary: Warn about string literal + character
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: veksler@il.ibm.com
Consider:
void f(const std::string &a, std::string & b)
{
b+= "_" + a[1];
}
Although syntactically correct, this code is most certainly buggy:
this is not Java and "_" is not a string object.
When compiling C++, and maybe C, and gcc encounteres
<string literal> operator+ <char value>
it should issue a warning.
More information about the Gcc-bugs
mailing list