[Top][All Lists]

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

[Tinycc-devel] Patch: Permit certain pointer assignments (grischka-2005-

From: David A. Wheeler
Subject: [Tinycc-devel] Patch: Permit certain pointer assignments (grischka-2005-09-25 case_7)
Date: Thu, 03 May 2007 09:56:23 -0400 (EDT)

The attached patch permits certain pointer assignments (grischka-2005-09-25 
case_7).  Applies cleanly to Landley fork, should also apply cleanly to 


Permit certain pointer assignments (grischka-2005-09-25 case_7)
This patch was originally posted in grischka's 2005-09-25 email as
"required fix" case_7 to compile gcc 2.95. It was tweaked by
David A. Wheeler to merge the test case into the standard tcc test suite.

The C99 spec involving this is complicated; see section 6.5.16
(assignment), section 6.2.7 (compatible type and composite type),
and section 6.7.2 (type specifiers). In C99, when they're in separate
translation units, the tag names (if given) must match.

In practice, given:
    struct _s1 { int a, b, c; } *p1 = NULL;
gcc will accept the following assignment without even a warning:
    struct _s2 { int a, b, c; } *p2 = p1;
(Notice that the struct tags are different, but no warning is given.)
This kind of assignment is likely in C programs using OO techniques, so 
forbidding them (as tcc currently does) is undesirable.
Note that this patch gives warnings in cases where gcc would not even
give a warning.  The warning is plausible (and highly recommended
in some situations), so it's retained.

--- David A. Wheeler 

Attachment: grischka7.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]