strangest systems I've sent email from

Maciej W. Rozycki macro at linux-mips.org
Sun May 22 12:09:26 CDT 2016


On Sun, 22 May 2016, Guy Dawson wrote:

> >> I'm not even sure
> >
> >>       size_t foo = (size_t)-1;
> >
> >> is legal,
> >
> > In C++, I don't know.  In C, I'm fairly sure it's legal.
> >
> >> or even does what I expect it to do (namely---set foo to the largest
> >> size_t value possible (pre C99).
> >
> > I'm not sure it does that.  If you want that, I think you want
> >
> >        size_t foo = -(size_t)1;
> 
> While I think that
> 
>     size_t foo = (size_t)(-1);
> 
> is what C would interpret as being meant. What the size of the thing that
> by default, in this implementation, -1 would be stored in.

 Why bother?  Won't:

	size_t foo = ~0UL;

do (~0ULL for C99)?  Or is it just an example for the purpose of general 
consideration rather than a solution for a specific problem?

  Maciej


More information about the cctalk mailing list