Paul-Antoine Arras wrote:
[...]/libgomp/parallel.cc:445:14: error: comparison of integer
expressions of different signedness: ‘int’ and ‘unsigned int’
[-Werror=sign-compare]
445 | return tid == gomp_thread ()->ts.team_id;
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Is the correct/preferable fix to change the 'GOMP_has_masked_thread_num'
API (that is, 'unsigned kind'), or cast locally (which expression?)?
In lower_omp_master, filter is treated as integer_type_node (rather
than unsigned_type_node). Similarly, in the OpenMP API,
omp_get_thread_num is defined with an (signed) int return type.
However, OpenMP defines a "thread number" as "a non-negative number".
Well, the reason that 'unsigned' cannot be used in API routines is that
Fortran so far does not support 'unsigned' (even though there was a
draft proposal, which gfortran implemented, activated with -funsigned).
Thus, OpenMP just uses 'int' and not 'unsigned' in cases where it would
be possible. (There are cases where the normal value is nonnegative -
but negative might appear as error indication or in case of device
numbers, there exist named constants that are negative and imply
something special. For threads, we currently don't have – and I also do
no really see a case where we want to have those.)
I would be of the opinion to cast tid to unsigned, but I may be
missing something.
This seems to be the easiest. On my side, the change looks good. (And
falls under obvious.)
Tobias