This is the mail archive of the gcc-patches@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]

Re: [gomp] PR24505 mixed types in predicate


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


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