Thread overview
[Issue 5821] New: Calling spawn in std.concurrency without all the parameters required by void function(T) fn
Apr 08, 2011
Jose Garcia
Apr 12, 2011
Andriy
Jun 05, 2011
yebblies
April 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5821

           Summary: Calling spawn in std.concurrency without all the
                    parameters required by void function(T) fn
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: jsancio@gmail.com


--- Comment #0 from Jose Garcia <jsancio@gmail.com> 2011-04-08 13:33:50 PDT ---
I am not sure if this a language, compiler, or library issue but when you call spawn without passing all the parameters required by the fn it can either segfault if you are lucky or worst yet have an unpredictable behavior.

For example the following code will compile and execute:

import std.concurrency;

void main()
{
   spawn(&fun);
}

void fun(int i) {}

My intuition is that the code above should not compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5821


Andriy <andrden@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrden@gmail.com


--- Comment #1 from Andriy <andrden@gmail.com> 2011-04-12 08:55:29 PDT ---
Seems more like it's language:
  arg: 100
  arg: 134851556 (any number actually)
is printed by the following which should not compile:

import std.stdio;

void func(int value){
    writeln("arg: ",value);
}

void myspawn(T...)( void function(T) fn, T args ){
    fn(args);
}

void main(){
    myspawn(&func,100);
    myspawn(&func);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5821


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-06-04 22:52:55 PDT ---
With only the function pointer as an argument, spawn becomes:
void spawn(void function() fn)
and &fun is (incorrectly) implicitly converted to void function() fn.

*** This issue has been marked as a duplicate of issue 3797 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------