- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I've encountered a compiler bug that causes the index variable in cilk_for loops to be declared in their parent's scope. I've observed it for gcc 4.8 and 4.9. I've only been able to reproduce the bug when the cilk_for loops appear in templatized code. I've attached a minimal working example which you can compile to reproduce the bug. The relevant portion of code demonstrating the bug is also at the end of this post.
Cheers,
Tim
template<typename T>
void foo() {
cilk_for(int i = 0; i < 5; i++) {
printf("Loop iter: %d",i);
}
// Will get redeclaration error for 'int i'.
cilk_for(int i = 0; i < 5; i++) {
printf("Loop iter: %d",i);
}
}
void bar() {
cilk_for(int i = 0; i < 5; i++) {
printf("Loop iter: %d",i);
}
cilk_for(int i = 0; i < 5; i++) {
printf("Loop iter: %d",i);
}
}
int main(int argc, char **argv)
{
bar(); // compiles.
foo<int>(); // doesn't compile.
return 0;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello tfk,
Thank you for reporting this bug. I will look into this and get back to you as soon as I get a fix.
Thanks,
Balaji V. Iyer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This bug still appears in the latest versions of gcc on the cilkbranch (4.9) and other (4.8). This is an annoying issue as it prevents easily porting existing cilk code that currently uses icc to gcc, as well as making it difficult to parallelize real applications using gcc with cilk (since real c++ applications tend to use templates!)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page