pointer assignement
LLeweLLyn Reese
llewelly@lifesupport.shutdown.com
Mon Aug 11 01:54:00 GMT 2003
Mikhail Posypkin <posypkin@ispras.ru> 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.
More information about the Gcc-help
mailing list