public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38650]  New: [4.3/4.4 regression] Trouble with volatile and #pragma omp for
@ 2008-12-28  0:23 reichelt at gcc dot gnu dot org
  2008-12-28  0:24 ` [Bug c++/38650] " reichelt at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2008-12-28  0:23 UTC (permalink / raw)
  To: gcc-bugs

There is some strange behavior with #pragma omp for and volatiles:

=================================
void foo()
{
  volatile int i, j = 1;
#pragma omp for
  for (i = 0; i < j; i += 1)
    ;
}
=================================

bug.cc: In function 'void foo()':
bug.cc:4: internal compiler error: in gimplify_omp_for, at gimplify.c:5880
Please submit a full bug report, [etc.]

A similar code snippet (using ++i instead of i+=1 as incrememt) is accepted:

=================================
void foo()
{
  volatile int i, j = 1;
#pragma omp for
  for (i = 0; i < j; ++i)
    ;
}
=================================

Another slight variation (using i<1 instead of i<j as loop condition)
is rejected:

=================================
void foo()
{
  volatile int i;
#pragma omp for
  for (i = 0; i < 1; ++i)
    ;
}
=================================

bug.cc: In function 'void foo()':
bug.cc:5: error: invalid controlling predicate

The above only holds for the C++ frontend since GCC 4.3.0.
With the C frontend or GCC 4.2.x all three snippets compile fine.


I looked into the specification of OpenMP 3.0 and found nothing forbidding
the use of volatiles as loop counters. On the other hand volatile is IMHO
against the semantics of parallel for where magically changing loop counters
would make no sense. Maybe that's even a defect of the OpenMP specification.


-- 
           Summary: [4.3/4.4 regression] Trouble with volatile and #pragma
                    omp for
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, rejects-valid, monitored, 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=38650


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-38650-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-06-27 11:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-28  0:23 [Bug c++/38650] New: [4.3/4.4 regression] Trouble with volatile and #pragma omp for reichelt at gcc dot gnu dot org
2008-12-28  0:24 ` [Bug c++/38650] " reichelt at gcc dot gnu dot org
2008-12-28 17:52 ` jakub at gcc dot gnu dot org
2008-12-28 20:08 ` jakub at gcc dot gnu dot org
2008-12-28 20:12 ` [Bug c++/38650] [4.3 " jakub at gcc dot gnu dot org
2008-12-29 23:01 ` rguenth at gcc dot gnu dot org
2009-01-24 10:28 ` rguenth at gcc dot gnu dot org
2009-08-04 12:46 ` rguenth at gcc dot gnu dot org
2010-05-22 18:28 ` rguenth at gcc dot gnu dot org
     [not found] <bug-38650-4@http.gcc.gnu.org/bugzilla/>
2011-06-27 11:57 ` rguenth at gcc dot gnu.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).