digitalmars.D.bugs - [Issue 8227] New: Anonymous member variable of struct get's it's arguments shifted when called.
- d-bugmail puremagic.com (39/39) Jun 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8227
http://d.puremagic.com/issues/show_bug.cgi?id=8227 Summary: Anonymous member variable of struct get's it's arguments shifted when called. Product: D Version: D2 Platform: x86_64 URL: http://stackoverflow.com/questions/10984930/creating-c urryable-functions-with-lambdas-in-d-doesnt-work-as-cl ass-struct-meme OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: GenericNPC gmail.com --- Comment #0 from IdanArye <GenericNPC gmail.com> 2012-06-11 14:32:06 PDT --- I created a struct with an anonymous function member variable: struct S { const foo=function(int x,int y,int z)=>x; } When I create an instance of S and call the function with three arguments, the arguments get shifted: x gets junk data, y gets the first argument, z gets the second argument, and the third argument is lost. If I declare foo in the global scope of the module, the arguments are passed the way they should - x gets the first argument, y gets the second argument, z gets the third argument. If I declare foo as a member variable of a class, I get a segmentation fault when I try to call foo. Making foo a static, shared, or __gshared member does not solve the problem. Declaring foo's type explicitly *DOES* solve the problem: int function(int,int,int) foo=function(int x,int y,int z)=>x; this does work. I have encountered this bug on DMD64 D Compiler v2.059 running on Arch Linux 3.3.8-1. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 11 2012