------- Additional Comments From kst at mib dot org  2005-07-27 19:34 -------
I misused the term "compatible" above (and I think the standard itself
is sometimes a bit loose about the term). 

All references are to the C99 standard.  I think the C90 rules are the
same or very similar.

6.7.8p11:
    
    The initializer for a scalar shall be a single expression,
    optionally enclosed in braces. The initial value of the object
    is that of the expression (after conversion); the same type
    constraints and conversions as for simple assignment apply, 
    taking the type of the scalar to be the unqualified version of
    its declared type.

6.5.16.1p1 (Simple assignment):

    One of the following shall hold:
    [...]
    -- both operands are pointers to qualified or unqualified versions
       of compatible types, and the type pointed to by the left has 
       all the qualifiers of the type pointed to by the right;

6.7.5.1p2:

    For two pointer types to be compatible, both shall be identically 
    qualified and both shall be pointers to compatible types.
    
6.2.5p14:

    The type char, the signed and unsigned integer types, and the 
    floating types are collectively called the basic types. Even if
    the implementation defines two or more basic types to have the
    same representation, they are nevertheless different types. (34)

6.2.5p15:

    The three types char, signed char, and unsigned char are 
    collectively called the _character types_. The implementation shall
    define char to have the same range, representation, and behavior
    as either signed char or unsigned char. (35)
  
Footnote 35:

    CHAR_MIN, defined in <limits.h>, will have one of the values 
    0 or SCHAR_MIN, and this can be used to distinguish the two
    options. Irrespective of the choice made, char is a separate type
    from the other two and is not compatible with either.
    
For an initialization of a char object, there's an implicit conversion,
even though types char and signed char are not compatible.

    signed char sc = 'x';
    char c = sc;     /* implicit conversion */
    
There is no implicit conversion for pointer types other than void*:

    signed char *psc = &sc;
    char *pc = psc;   /* illegal, incompatible types */


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23087

Reply via email to