This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] PR24505 mixed types in predicate
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Aldy Hernandez <aldyh at redhat dot com>, dnovillo at redhat dot com, rth at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Mon, 31 Oct 2005 03:01:42 -0500
- Subject: Re: [gomp] PR24505 mixed types in predicate
- References: <20051030203501.GA17778@redhat.com> <200510302041.j9UKfEC2004758@earth.phy.uc.edu>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sun, Oct 30, 2005 at 03:41:14PM -0500, Andrew Pinski wrote:
> > Index: c-omp.c
> > ===================================================================
> > --- c-omp.c (revision 105937)
> > +++ c-omp.c (working copy)
> > @@ -196,7 +196,36 @@
> > else
> > {
> > bool cond_ok = false;
> > + tree op0 = TREE_OPERAND (cond, 0);
> > + tree op1 = TREE_OPERAND (cond, 1);
> >
> > + /* 2.5.1. The comparison in the condition is computed in the type
> > + of DECL, otherwise the behavior is undefined.
> > +
> > + For example:
> > + long n; int i;
> > + i < n;
> > +
> > + according to ISO will be evaluated as:
> > + (long)i < n;
> > +
> > + We want to force:
> > + i < (int)n; */
>
> This seems to me a defect in the OpenMP standard as it really should not confict
> with what the C standard says.
>
> If the OpenMP standard really says this, it seems like someone should report
> that with and without the pragma changes the behavior.
The #pragma of course changes behaviour, the #pragma omp for is not supposed
to preceed any for loop, but only a loop that obeys the OpenMP standard
requirements. One of the requirement is that the computation of number of
loops (particularly that for for (var = lb; var relational-op; var += incr) ...
b - lb + incr computation or any intermediate result must be representable
in var's type (which needs to be signed integral type)). Otherwise, the
behaviour is unspecified. So, the programmer by adding #pragma omp for
told the compiler that it doesn't matter whether the condition is computed
as (long) i < n or i < (int) n.
Jakub