www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5821] New: Calling spawn in std.concurrency without all the parameters required by void function(T) fn

reply d-bugmail puremagic.com writes:
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



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: -------
Apr 08 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5821


Andriy <andrden gmail.com> changed:

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



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: -------
Apr 12 2011
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jun 04 2011