'char **' <-> 'unsigned char **' and aliasing/punning in C / GNU C
Pedro Alves
palves@redhat.com
Sat Mar 9 00:56:00 GMT 2013
Hello,
FYI, I got word back from Joseph Meyers on a separate
channel, and his answer was:
It's not valid. char and unsigned char can alias, but
not char * and unsigned char *.
Regarding char * and const char *, I then asked:
Can char * and const char * alias?
He said:
Not in C (but they can in C++, where you can implicitly convert from char
** to const char *const *, although not from char ** to const char **).
We're going to avoid these casts in GDB then, and do instead
things like:
gdb_byte *buf;
char *c;
...
bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR,
"avr.io_reg", &buf);
c = (char *) buf;
Thanks a lot,
--
Pedro Alves
More information about the Gcc-help
mailing list