From: Mikael Pettersson <mikpe@csd.uu.se>
To: jamagallon@able.es
Cc: linux-kernel@vger.kernel.org
Subject: Re: bad function ptrs - is it dangerous ?
Date: Wed, 2 Oct 2002 10:06:00 +0200 (MET DST) [thread overview]
Message-ID: <200210020806.KAA17736@kim.it.uu.se> (raw)
On Wed, 2 Oct 2002 00:51:25 +0200, J.A. Magallon wrote:
>int (*pf)(data *);
>int f(data*);
>
>so you can:
>
>pf = f;
>pf(data).
>
>Fine. But what happens if:
>
>void (*pf)(data *);
>int f(data*);
>
>pf = f; // gcc happily swallows, gcc-3.2 gives a warning.
>pf(data).
Undefined Behaviour. I can easily imagine cases where, depending
on the calling convention and the actual return type, things could
go very very wrong. Consider struct returns...
This case, returning an int to a caller expecting void, is likely
to work on most normal machines -- the int would go into a GP result
register, and the GP result register is typically always part of the
caller-save set. The code is still utter crap, however.
>The (in)famous graphics driver all you know is doing this with the
>copy_info op for gart...
<censored>
/Mikael
next reply other threads:[~2002-10-02 8:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-02 8:06 Mikael Pettersson [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-10-01 22:51 J.A. Magallon
2002-10-01 23:56 ` Burton Samograd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200210020806.KAA17736@kim.it.uu.se \
--to=mikpe@csd.uu.se \
--cc=jamagallon@able.es \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®