This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11240] Weirdness with reverse_iterator<const char*>
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Oct 2003 19:39:34 -0000
- Subject: [Bug c++/11240] Weirdness with reverse_iterator<const char*>
- References: <20030618145210.11240.ysbeer@af.org.za>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11240
------- Additional Comments From bangerth at dealii dot org 2003-10-16 19:39 -------
Here's something odd: this test fails with all versions of gcc
------------------------------
#include <cassert>
struct R1 {
const char* p;
R1(const char* p) : p(p) { }
};
int main() {
const char s[] = "0";
R1 r1 = R1(s);
assert( r1.p == s );
}
----------------------------
whereas the following succeeds:
----------------------------
#include <cassert>
struct R1 {
const char* p;
};
int main() {
const char s[] = "0";
R1 r1 = {s};
assert( r1.p == s );
}
--------------------------------
I don't know what's going on. The first test also fails if one changes
the type of p to "const char * const". In the debugger, this looks
like so:
(gdb) p &s[0]
$5 = 0xbffff00a "0"
(gdb) p r1.p
$6 = 0x804868f "0"
It looks as if "s" were in the read-only part of memory, while r1.p is
pointing into read-write memory. But I don't know enough about these issues
to speculate further.
W.