- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
When I played with array operations in Cilk Plus, I found the same assignment might return different results with
Is it an error or a bug? Thanks.
Configuration:
gcc (Ubuntu 5.3.0-3ubuntu1~14.04) / g++ (Ubuntu 5.3.0-3ubuntu1~14.04)
Code:
#include <stdio h> #include < . / cilk cilk . h> mainint ( ){ int a99]; [ int n = 20;for ( i=0;i<n;i++) int a [ ] = i + 1; i a 0:5] = a [ 10:5]; // [ <-------- for ( int i=0;i<n;i++)printf "a ( %d] = %d\n",i,a); [ return 0;}
Compile with
gcc arr.c -fcilkplus -lcilkrts
. /a. out a[ 0] = 11 a[ 1] = 10 a[ 2] = 9 a[ 3] = 8 a[ 4] = 7 a[ 5] = 6 a[ 6] = 7 a[ 7] = 8 a[ 8] = 9 a[ 9] = 10 a[ 10] = 11 a[ 11] = 12 a[ 12] = 13 a[ 13] = 14 a[ 14] = 15 a[ 15] = 16 a[ 16] = 17 a[ 17] = 18 a[ 18] = 19 a[ 19] = 20
Compile with g++:
g++ arr.c -fcilkplus -lcilkrts
. /a. out a[ 0] = 11 a[ 1] = 12 a[ 2] = 13 a[ 3] = 14 a[ 4] = 15 a[ 5] = 6 a[ 6] = 7 a[ 7] = 8 a[ 8] = 9 a[ 9] = 10 a[ 10] = 11 a[ 11] = 12 a[ 12] = 13 a[ 13] = 14 a[ 14] = 15 a[ 15] = 16 a[ 16] = 17 a[ 17] = 18 a[ 18] = 19 a[ 19] = 20
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, that is really strange. It does appear that there is a serious bug in the C compiler (gcc) but not the C++ compiler (g++). Does the same thing happen if you use two separate arrays (i.e., a[0:5] = b[10:5])? (I'm guessing no.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the result of two separate arrays is still the same. It seems that
Initially, the code was saved in
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page