public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker
@ 2014-03-19 12:36 izamyatin at gmail dot com
  2015-08-11 20:45 ` [Bug middle-end/60586] " arch.robison at hotmail dot com
  2015-09-03  0:00 ` hjl at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: izamyatin at gmail dot com @ 2014-03-19 12:36 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-03  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 12:36 [Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker izamyatin at gmail dot com
2015-08-11 20:45 ` [Bug middle-end/60586] " arch.robison at hotmail dot com
2015-09-03  0:00 ` hjl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).