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"


Andrew Pinski wrote:
>
> On Jul 5, 2006, at 2:36 AM, Yuri Pudgorodsky wrote:
>
>> 1) with direct cast: (int (*)(int)) foo
>> - warn/trap since 3.x
>> 2) with cast through void fptr: (int (*)(int)) (int(*)()) foo
>> - warn/trap since 4.2 current
>
> I don't see why you are invoking this undefined behavior anyways.
> What are you trying to do?  I don't see how this can ever work really
> anyways even if since most targets don't pass arguments via the stack.
> Yes x86 will most likely work but nothing else, even x86_64 will not work
> as floating point is passed via the SSE registers.
>
> -- Pinski

As I said, that is in openssl code - they have macros casting function
pointers
to args with different pointer type - e.g. foo(...., char * p, ....) ->
foo(....,struct bar *p, ....).

For some obsure reason, they prefer doing that instead of casting the
calling args itself
(for type safety, e.g compile-time time check of function args?)




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