pointer assignement

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

 



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@xxxxxxxxx




[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