This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [Ping]FW: [PATCH] Cilk Plus merging to trunk (2 of n)
On Wed, 24 Oct 2012, Iyer, Balaji V wrote:
> > Where in the patch you use int for the size of something (e.g. a list) on the host,
> > please use size_t.
>
> Can you please give me an example where I am violating this rule? Here
> is a link to the last submitted patch in case you need it
> (http://gcc.gnu.org/ml/gcc-patches/2012-10/msg00431.html).
For example, see build_array_notation_expr. The variables ii, jj,
rhs_list_size, lhs_list_size should be size_t. I see no reason in
principle those lists should not have 2^31 or more elements, on a 64-bit
host. Unless there is some reason why, whatever the host and target, the
values of some variable in the compiler could never need to exceed 2^31,
int is probably not the right type for that variable.
> Also you mention "host" and "target." What do you exactly mean by that?
> I generally use those terms in like a cross-compiler setting (i.e. host
> = the machine on which you are compiling and target means the target
> architecture you are compiling for).
That's what I mean. You're measuring the size of an array on the host, so
use size_t not int to measure that size. If you were measuring something
on the target, you might need HOST_WIDE_INT (for example, a compiler on a
32-bit host can reasonably build objects for a 64-bit target that declare
arrays with more than 2^31 elements, so size_t is not the right type to
use in the compiler for the size of a target array).
--
Joseph S. Myers
joseph@codesourcery.com