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

Re: Relaxing -Wsign-compare


On Fri, Sep 21, 2001 at 05:48:31PM -0000, Morten Welinder wrote:
> 
> That's a very popular non-solution.  Normally the index value is
> actually used, like for example:
> 
> for (i = 0; i < sizeof (foo) / sizeof (foo[0]); i++)
>   printf ("%d\n", i);
> 
> With "int", the program is perfectly fine and portable.  With "size_t",
> it isn't, if I understand things right.  There's no guarantee that "%d"
> matches size_t.  Having to cast i when used is not appealing.
> 
With 'int' the program is not portable if the array is equal or larger than
32 KByte. Example is Turbo-C for Atari ST/TT.

You have also problems with Arrays equal and larger than 2 GByte on every 64
bit machine.

-- 
Frank Klemm


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