This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/35652] New: Location information incorrect on string bounds warning
- From: "simon_baldwin at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Mar 2008 21:06:40 -0000
- Subject: [Bug c++/35652] New: Location information incorrect on string bounds warning
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following demonstrates a location error in a string bounds warning message:
$ cat /tmp/c.cc
#include <string>
int main() {
// blank line padding, could also be code...
//
//
//
//
//
//
//
//
//
std::string s = "";
s += 'x' + "y"; // bogus
}
$ g++ -O2 -c /tmp/c.cc
/tmp/c.cc: In function 'int main()':
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/.../i686-unknown-linux-gnu/include/c++/4.3.0/bits/char_traits.h:262: warning:
offset outside bounds of constant string
/.../i686-unknown-linux-gnu/include/c++/4.3.0/bits/char_traits.h:262: warning:
offset outside bounds of constant string
The erroneous line is line 14, but g++ reports the problem (multiple times) at
line 2 and in an STL header file. The same behavior occurs in g++ 4.2.1,
4.1.1, 4.0.3, and 4.0.2. It does not occur in gcc 3.4.5.
Also, there is no warning emitted with -O0, for some reason.
--
Summary: Location information incorrect on string bounds warning
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: simon_baldwin at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35652