This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 4.2 more strict check for "function called through a non-compatible type"


Ian Lance Taylor wrote:

Mike Stump <mrs@apple.com> writes:



On Jul 4, 2006, at 5:18 PM, Andrew Pinski wrote:


And I posted a patch to do the same in Objective-C mode as C mode :).
http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01013.html


Is the reason that Objective-C was excluded been fixed? If so, while
I don't like the semantics in place now, I'd rather have consistency
with C/C++. :-(



A version of Andrew's patch was checked in on 2005-05-24, by Ziemowit Laski. The languages are currently consistent.

Ian


If so, why I'm able to compile the casted pointer example with gcc-4.2-20060701 snapshot
in objective-c mode without warning/trap inserted?


Exactly speaking, all four front-ends behave different.

yur@cloud ~/tmp $ cat bbb1.c
static double foo(double arg)
{
 return arg;
}

int bar(int d)
{

 d = ((int (*) (int)) (void(*)())foo)(d);
 return d*d;
}

yur@cloud ~/tmp $ gcc -v
gcc version 4.2.0-alpha20060701  (experimental) (Gentoo 4.2.0_alpha20060701)
yur@cloud ~/tmp $ gcc -O3 bbb1.c -c
bbb1.c: In function 'bar':
bbb1.c:9: warning: function called through a non-compatible type
bbb1.c:9: note: if this code is reached, the program will abort
yur@cloud ~/tmp $ gcc -x c++ -O3 bbb1.c -c
yur@cloud ~/tmp $ gcc -x objective-c -O3 bbb1.c -c
bbb1.c: In function 'bar':
bbb1.c:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.
yur@cloud ~/tmp $ gcc -x objective-c++ -O3 bbb1.c -c
bbb1.c: In function 'int bar(int)':
bbb1.c:6: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]