This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26691] New: Wrong code for constructor with default value
- 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: 15 Mar 2006 10:20:58 -0000
- Subject: [Bug c++/26691] New: Wrong code for constructor with default value
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The compiler creates wrong code for the following valid OpenMP-C++
code snippet when compiled with "-fopenmp":
=======================================
#include<cstdio>
struct A
{
int n;
A(int i=3) : n(i) {}
};
int main()
{
A a;
#pragma omp parallel private (a)
std::printf("%d\n", a.n);
return 0;
}
=======================================
Instead of OMP_NUM_THREADS times the output "3"
I get one "1" and OMP_NUM_THREADS-1 times "0".
In addition I get a bogus warning with "-O -Wall -fopenmp"
which is probably just another symptom of the problem above:
bug.cc: In function 'void _Z3foov.omp_fn.0(void*)':
bug.cc:6: warning: 'i' is used uninitialized in this function
--
Summary: Wrong code for constructor with default value
Product: gcc
Version: 4.2.0
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=26691