[RFC] a char* that doesn't alias everything

Dan Nicolaescu dann@ics.uci.edu
Sun Jan 27 18:29:00 GMT 2002


"Joseph S. Myers" <jsm28@cam.ac.uk> writes:

  > On Sun, 27 Jan 2002, Dan Nicolaescu wrote:
  > 
  > > The C standards specify that a char* should alias everything.
  > > Sometimes this is quite undesirable. 
  > > 
  > > So here is an implementation of an attribute that only applies to
  > > "char" types and allows char* to not alias all other objects.
  > > 
  > > Then name of the attribute could surely be improved...
  > > 
  > > Is an attribute the way to go about implementing this? 
  > > Or it should be a compiler built-in type?  Comments? 
  > 
  > It should be a built-in type:
  > 
  > * It should be usable for implementing <stdint.h>'s int8_t and uint8_t;  
  > those are standard names for 8-bit types which are not required to have
  > the aliasing properties of character types.
  > 
  > * Therefore, it must be a pair of extended integer types; one signed, one
  > unsigned.
  > 
  > * Being C99 extended types means the types mustn't be compatible with
  > char, signed char or unsigned char.  For example, assignments between
  > "signed char *" and "int8_t *" should not be allowed, if int8_t is such a
  > type.

Wouldn't it be useful to be able to assign string literals to 
int8_t*s ? Or use string functions on int8_t*s ? 

Basically if char* is not used to access things that are not chars,
anything that is a char could be replaced by an int8_t (on platforms
that chars are 8-bit). 
Wouldn't making them char and int8_t incompatible make this harder? 

Just my 2 cents... 



More information about the Gcc-patches mailing list