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 04:35:01PM -0400, Aldy Hernandez wrote:
> Hi guys!
> 
> 2.5.1 specifies that the condition in a for loop is computed in the
> type of the loop variable, otherwise the behavior is undefined.
> 
> This patch fixes the problem in PR24505.
> 
> Bootstrapped and regtested on ppc-linux for C and C++.

I think a warning should be issued in that case, unless in
iteration_var relational_op b
the compiler can prove that (__typeof (iteration_var)) b == b,
similarly to how we warn about iteration var being unsigned.
If b is unsigned, the warning should be IMHO unconditional though,
unless iteration_var is already unsigned too (which means we warned
already).

So say
#pragma omp for
  for (int i = 0; i < 10L; i++)
    ...
would not warn.

Have you tried also b having floating point type?
#pragma omp for
  for (int i = 0; i < 10.2; i++)
    ...

> 	PR gomp/24505
> 	* c-omp.c (c_finish_omp_for): Canonicalize condition.
> 	* testsuite/gcc.dg/gomp/for-15.c: New.

	Jakub


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