Why does casting a function generate a run-time abort?

Ziemowit Laski zlaski@apple.com
Fri Jun 18 20:54:00 GMT 2004


On 18 Jun 2004, at 12.00, Geoffrey Keating wrote:

> Ziemowit Laski <zlaski@apple.com> writes:
>
>> On 17 Jun 2004, at 22.55, Eric Botcazou wrote:
>>
>>>> Could someone shed some light on this?
>>>
>>> The behaviour is undefined in C at run-time (6.3.2.3 §8) so
>>> generating an
>>> abort is permitted.  This should not trigger in Objective-C (at
>>> least that's
>>> how it was written for 3.4).
>>
>> Right; there is an ugly 'if(!c_dialect_objc())' in front of the whole
>> thing.  Although I do see that an abort is indeed permitted under the
>> circumstances, I'm still mystified as to why this became an issue in
>> the first place.  Why not just construct a function call using the
>> signature specified in the cast?  Aside from not being able to inline
>> the call, I'm not quite sure what the problem is...
>
> Because if you *do* try to inline the call, you will get an ICE.

So don't inline it.  :-)  In fact, you can even produce an informative 
warning "Could not inline call due to incompatible cast".

--Zem



More information about the Gcc mailing list