This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: converting function pointers to/from object pointers
- From: Josef Wolf <jw at raven dot inka dot de>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>, gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 24 Aug 2015 21:33:19 +0200
- Subject: Re: converting function pointers to/from object pointers
- Authentication-results: sourceware.org; auth=none
- References: <20150824144924 dot GI29006 at raven dot inka dot de> <CAH6eHdSRk67RuT5k2egxMUT8RdihcHED2+nrgrBLG5anKEw97Q at mail dot gmail dot com> <20150824152320 dot GB10100 at gate dot crashing dot org>
On Mo, Aug 24, 2015 at 10:23:20 -0500, Segher Boessenkool wrote:
> On Mon, Aug 24, 2015 at 03:53:54PM +0100, Jonathan Wakely wrote:
> > On 24 August 2015 at 15:49, Josef Wolf wrote:
> > > I have some old code, which worked fine with old GCC releases, but
> > > fails with current GCC.
> > >
> > > With current GCC, I get a warning:
> > >
> > > "ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]"
> > >
> > > and the system crashes.
> >
> > That warning is not likely to be the reason it crashes.
Right. But warnings tend to be there for a reason. So I'm trying to find out
how to correctly handle this situation.
> > You should look at *where* it crashes, and *why*. Is it dereferencing
> > an invalid pointer? Is there a misaligned access?
I think Martin Sebor is right here.
> Right. Also you should use -fno-strict-aliasing since you play non-standard
> pointer games.
Could you elaborate more verbosely on this, please? I don't see where aliasing
problems could be hidden in the outlined code fragments.
--
Josef Wolf
jw@raven.inka.de