Re: pointer assignement

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

 



Mikhail Posypkin <posypkin@xxxxxxxxx> writes:

> Dear colleagues!
> 
> C99 gives the following limitations for a simple assigment operands
> types:
> 
> 6.5.16.1 Simple assignment
> 
> Constraints
> 1 One of the following shall hold:82)
> ? the left operand has qualified or unqualified arithmetic type and the right has
> arithmetic type;
> ? the left operand has a qualified or unqualified version of a structure or union type
> compatible with the type of the right;
> ? 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;
> ? one operand is a pointer to an object or incomplete type and the other is a pointer to a
> qualified or unqualified version of void, and the type pointed to by the left has all
> the qualifiers of the type pointed to by the right; or
> ? the left operand is a pointer and the right is a null pointer constant.
> 
> 
> According to this wording the following example is incorrectly typed:
> 
> int f()
> {
>         int *p, **q;
> 
>         p = q;
>         q = p;
> }
> 
> 
> But gcc-3.3 just prints a warning message (not error):
> 
> vulture@posypkin:~/tmp:)/export/home/gcc-3.3/bin/gcc -ansi -pedantic err.c
> err.c: In function `f':
> err.c:5: warning: assignment from incompatible pointer type
> err.c:6: warning: assignment from incompatible pointer type

The C99 standard only requires diagnostics. These are
    diagnostics. Rejection is not required.

> 
> Is it Ok that gcc permits illegal C programs or I don't understand
> something.

If you don't think this is ok, use -pedantic-errors, or -Werror.


[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