Re: 'char **' <-> 'unsigned char **' and aliasing/punning in C / GNU C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/8/13, Pedro Alves <palves@xxxxxxxxxx> wrote:
>
> 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 (&current_target, TARGET_OBJECT_AVR,
> 			    "avr.io_reg", &buf);
> c = (char *) buf;

Joseph is far more likely to be right than I am.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux