[Bug c++/11240] Weirdness with reverse_iterator<const char*>
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Thu Oct 16 19:39:00 GMT 2003
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.
More information about the Gcc-bugs
mailing list