This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24735] New: [gomp] "#pragma omp barrier" doesn't work in templates
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Nov 2005 15:32:24 -0000
- Subject: [Bug c++/24735] New: [gomp] "#pragma omp barrier" doesn't work in templates
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following program doesn't work correctly when compiled with -fopenmp:
==============================
#include<cstdio>
#include<omp.h>
#include<unistd.h>
template<int> void foo()
{
#pragma omp parallel
{
if (omp_get_thread_num()==0) sleep(1);
printf("ONE\n");
#pragma omp barrier
printf("TWO\n");
}
}
int main()
{
foo<0>();
return 0;
}
==============================
The output (with two threads) is:
ONE
TWO
ONE
TWO
If I make foo a non-template function, I get the correct output:
ONE
ONE
TWO
TWO
Maybe related to PR 24734.
--
Summary: [gomp] "#pragma omp barrier" doesn't work in templates
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: wrong-code, openmp
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24735