This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/26691] New: Wrong code for constructor with default value


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]