This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
pointer assignement
- From: Mikhail Posypkin <posypkin at ispras dot ru>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 10 Aug 2003 12:50:25 +0300
- Subject: pointer assignement
- Reply-to: Mikhail Posypkin <posypkin at ispras dot ru>
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
Is it Ok that gcc permits illegal C programs or I don't understand
something.
Please help my understanding,
Thank you in advance.
--
Best regards,
Mikhail mailto:posypkin@ispras.ru