[Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker
izamyatin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 19 12:36:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60586
Bug ID: 60586
Summary: [Cilk+] Parameters evaluation happens inside spawn
worker
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: izamyatin at gmail dot com
Following test (compiled with eg -O2 -fcilkplus -lcilkrts)
#include <stdio.h>
#include <cilk/cilk.h>
#include <unistd.h>
int noop(int x)
{
return x;
}
int post_increment(int *x)
{
sleep(1);
return (*x)++;
}
int main(int argc, char *argv[])
{
int m = 5;
int n = m;
int r = cilk_spawn noop(post_increment(&n));
int n2 = n;
cilk_sync;
printf("After sync: m = %d, n = %d, r = %d, n2 = %d\n", m, n, r, n2);
if (r != m || n2 != m + 1)
printf("FAILED\n");
else
printf("PASSED\n");
return 0;
}
outputs
After sync: m = 5, n = 6, r = 5, n2 = 5
FAILED
That happens because post_increment is called inside spawn worker which is
incorrect.
More information about the Gcc-bugs
mailing list