Re: Compiler crashes when taking address of function pointer
[Thread Prev] | [Thread Next]
- Subject: Re: Compiler crashes when taking address of function pointer
- From: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Date: Fri, 16 Jan 2015 23:09:27 -0800
- To: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Cc: Ryan <rymg19@xxxxxxxxx>, myrddin-dev@xxxxxxxxxxxxxx
Ok, for now:
var p : byte#
var i : std.intptr
p = somefunc castto(byte#)
i = somefunc castto(std.intptr)
Should work error free. Figuring out what exactly function addresses mean
semantically, and how they interact with closures, is something I'll have
to think about a bit more.
On Fri, 16 Jan 2015 22:55:48 -0800
Ori Bernstein <ori@xxxxxxxxxxxxxx> wrote:
> Sure; for a simple fix, I can allow casting from functions to pointers
> and back. I'm just trying to sort out what it would mean to, eg, deref
> a function pointer.
>
> And what happens to that code if/when I figure out environment capture
> for closures.
>
> On Fri, 16 Jan 2015 23:38:04 -0600
> Ryan <rymg19@xxxxxxxxx> wrote:
>
> >
> >
> > Ori Bernstein <ori@xxxxxxxxxxxxxx> wrote:
> > >Interesting. That shouldn't happen. It's crashing because the backend
> > >puts
> > >function addresses into registers as rvalues if they're not being
> > >called.
> > >
> > >I haven't hit it because I haven't needed pointer to a function yet;
> > >functions already can be passed around without taking their address:
> > >
> > > const each = {sl : int[:], f : (int -> void)
> > > ...
> > > }
> > >
> > > each([1,2,3][:], somefunc)
> >
> > Well, it has to do with the kernel writing. I need to split a function's address into the higher and lower bits.
> >
> > I think there's a way I can get around it, though. Just though I should report this anyway.
> >
> > >
> > >should work just fine.
> > >
> > >On Fri, 16 Jan 2015 14:52:29 -0600
> > >Ryan Gonzalez <rymg19@xxxxxxxxx> wrote:
> > >
> > >> Example:
> > >>
> > >> const g = {; ->}
> > >> const f = {; var addr = &g}
> > >>
> > >> I get this:
> > >>
> > >> ryan@DevPC-LX:~/langtest/myr$ 6m bug.myr
> > >> 6m: gengas.c:128: locprint: Assertion `(spec == 'r' &&
> > >isintmode(l->mode))
> > >> || (spec == 'f' && isfloatmode(l->mode)) || spec == 'v' || spec ==
> > >'x' ||
> > >> spec == 'u'' failed.
> > >> Aborted (core dumped)
> > >> ryan@DevPC-LX:~/langtest/myr$
> > >>
> > >> --
> > >> Ryan
> > >> If anybody ever asks me why I prefer C++ to C, my answer will be
> > >simple:
> > >> "It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that
> > >was
> > >> nul-terminated."
> > >> Personal reality distortion fields are immune to contradictory
> > >evidence. -
> > >> srean
> > >> Check out my website: http://kirbyfan64.github.io/
> >
> > --
> > Sent from my Android phone with K-9 Mail. Please excuse my brevity.
> > Check out my website: http://kirbyfan64.github.io/
> >
>
>
> --
> Ori Bernstein <ori@xxxxxxxxxxxxxx>
>
--
Ori Bernstein <ori@xxxxxxxxxxxxxx>
| Compiler crashes when taking address of function pointer | Ryan Gonzalez <rymg19@xxxxxxxxx> |
| Re: Compiler crashes when taking address of function pointer | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
| Re: Compiler crashes when taking address of function pointer | Ryan <rymg19@xxxxxxxxx> |
| Re: Compiler crashes when taking address of function pointer | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
- Prev by Date: Re: Compiler crashes when taking address of function pointer
- Next by Date: Minor syntax change.
- Previous by thread: Re: Compiler crashes when taking address of function pointer
- Next by thread: Minor syntax change.
- Index(es):