public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26691]  New: Wrong code for constructor with default value
@ 2006-03-15 10:21 reichelt at gcc dot gnu dot org
  2006-03-15 12:58 ` [Bug middle-end/26691] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-03-15 10:21 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/26691] Wrong code for constructor with default value
  2006-03-15 10:21 [Bug c++/26691] New: Wrong code for constructor with default value reichelt at gcc dot gnu dot org
@ 2006-03-15 12:58 ` pinskia at gcc dot gnu dot org
  2006-03-15 13:09 ` [Bug c++/26691] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-15 12:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-03-15 12:58 -------
Hmm, the IR looks fine in .gimple:
    struct A a;

    __comp_ctor  (&a, 3);
    #pragma omp parallel private(a)
      {
        {
          int D.2487;

          D.2487 = a.n;
          printf (&"%d\n"[0], D.2487);
        } 
      }
    D.2488 = 0;
    return D.2488;

But broken in omplower:
    __comp_ctor  (&a, 3);
    {
      #pragma omp parallel private(a) [child fn: main.omp_fn.0 (???)]
        {
          __comp_ctor  (&a);
          D.2495 = a.n;
          D.2487 = D.2495;
          printf (&"%d\n"[0], D.2487);
          OMP_RETURN
        }
    }
    D.2488 = 0;
    return D.2488;

Looks like we don't create the correct ctor for a, the one with the 3 as an
agrument.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |middle-end
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-03-15 12:58:26
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26691


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/26691] Wrong code for constructor with default value
  2006-03-15 10:21 [Bug c++/26691] New: Wrong code for constructor with default value reichelt at gcc dot gnu dot org
  2006-03-15 12:58 ` [Bug middle-end/26691] " pinskia at gcc dot gnu dot org
@ 2006-03-15 13:09 ` pinskia at gcc dot gnu dot org
  2006-03-20 14:24 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-15 13:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-15 13:09 -------
Hmm, on second thought I think this is a front-end bug.
And here is a self contained testcase:
struct A
{
   int n;
   A(int i=3) : n(i) {}
};

int main()
{
    A a;
#pragma omp parallel private (a)
    if (a.n!=3)  __builtin_abort();

    return 0;
}


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |c++


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26691


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/26691] Wrong code for constructor with default value
  2006-03-15 10:21 [Bug c++/26691] New: Wrong code for constructor with default value reichelt at gcc dot gnu dot org
  2006-03-15 12:58 ` [Bug middle-end/26691] " pinskia at gcc dot gnu dot org
  2006-03-15 13:09 ` [Bug c++/26691] " pinskia at gcc dot gnu dot org
@ 2006-03-20 14:24 ` jakub at gcc dot gnu dot org
  2006-03-21 16:21 ` jakub at gcc dot gnu dot org
  2006-03-21 17:02 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-03-20 14:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-03-15 12:58:26         |2006-03-20 14:24:25
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26691


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/26691] Wrong code for constructor with default value
  2006-03-15 10:21 [Bug c++/26691] New: Wrong code for constructor with default value reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-03-20 14:24 ` jakub at gcc dot gnu dot org
@ 2006-03-21 16:21 ` jakub at gcc dot gnu dot org
  2006-03-21 17:02 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-03-21 16:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2006-03-21 16:21 -------
Subject: Bug 26691

Author: jakub
Date: Tue Mar 21 16:21:24 2006
New Revision: 112251

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112251
Log:
        PR c++/26691
        * cp-gimplify.c (cxx_omp_clause_apply_fn): Handle default arguments.

        * testsuite/libgomp.c++/pr26691.C: New test.

Added:
    trunk/libgomp/testsuite/libgomp.c++/pr26691.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-gimplify.c
    trunk/libgomp/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26691


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/26691] Wrong code for constructor with default value
  2006-03-15 10:21 [Bug c++/26691] New: Wrong code for constructor with default value reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-03-21 16:21 ` jakub at gcc dot gnu dot org
@ 2006-03-21 17:02 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-21 17:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-03-21 17:02 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26691


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-21 17:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-15 10:21 [Bug c++/26691] New: Wrong code for constructor with default value reichelt at gcc dot gnu dot org
2006-03-15 12:58 ` [Bug middle-end/26691] " pinskia at gcc dot gnu dot org
2006-03-15 13:09 ` [Bug c++/26691] " pinskia at gcc dot gnu dot org
2006-03-20 14:24 ` jakub at gcc dot gnu dot org
2006-03-21 16:21 ` jakub at gcc dot gnu dot org
2006-03-21 17:02 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).