C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Array Index in Range-based For Loops

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Thu, 2 Mar 2023 09:39:20 +0000
On Thu, 2 Mar 2023, 06:35 Thiago Macieira via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> On Wednesday, 1 March 2023 17:04:39 PST Edward Catmur via Std-Proposals
> wrote:
> > I'm not entirely sure that size_t can't promote to
> > int, although obviously it doesn't on any sensible platform.
>
> It's possible. Integer promotion rules say that only types of rank lesser
> than
> int can promote to int and only so long as all the values of that integer
> fit
> int, otherwise they promote to unsigned. Therefore, you'd need to find a
> platform where
>
> sizeof(size_t) < sizeof(int)
>
> That is permitted, but I don't think exists or has ever existed.
>

It exists, I had to fix libstdc++ for it recently:

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=75e562d2c4303d3918be9d1563284b0c580c5e45

(I mistakenly said I32LP16 in that commit msg but should have said
something like I32LL64P16, better obviously long can't be smaller than int,
but size_t can be unsigned short).


>

Received on 2023-03-02 09:39:35