Struct with lambda argument causes segfault at runtime

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 9 14:05:08 PDT 2014


On Sat, Aug 09, 2014 at 07:39:51PM +0200, Timon Gehr via Digitalmars-d wrote:
> On 08/09/2014 07:11 PM, H. S. Teoh via Digitalmars-d wrote:
> >
> >This causes a segfault at runtime. Moving the declaration of r inside
> >main() fixes the problem. Why?
> 
> My guess is it is just a missing diagnostic for the missing support
> for closures in CTFE.
> 
> You are effectively trying to do something like
> 
> auto foo(int a){
>     return (int x)=>x+a;
> }
> auto d=foo(2);
> 
> which fails with
> 
> Error: closures are not yet supported in CTFE

Aha! I think you're right. Moving declaration into main() and changing
it to enum (to force CTFE) causes the same problem. So, looks like it's
a missing check for an unsupported feature in CTFE.


T

-- 
Shin: (n.) A device for finding furniture in the dark.


More information about the Digitalmars-d mailing list