On Thu, Oct 16, 2025 at 11:58 AM Alejandro Colomar <[email protected]> wrote:
>
> Hi Richard,
>
> On Thu, Oct 16, 2025 at 11:02:04AM +0200, Richard Biener wrote:
> > On Wed, Oct 15, 2025 at 6:11 PM Michael Matz <[email protected]> wrote:
> [...]
> > > > But within the boolean class of integers, it makes no sense to use a
> > > > generic operator to get the limits, as there's only one type: bool.
> > > > Thus, you just hardcode true and false.
> > >
> > > I can envision different bool types (of different sizes for instance),
> > > where everything is naturally defined.  Maxof/Minof would then return the
> > > correctly typed variants of true and false.  But even that imagination
> > > isn't necessary to see that Maxof/Minof should "obviously" be defined for
> > > bool.
> >
> > If we ever expose vector bools as GNU extension then you get a new
> > "signed bool" with different _Minof/_Maxof (-1 and 0).
> >
> > typedef bool sbool __attribute__((signed_bool_precision(1)));
> >
> > _Minof (sbool) == 1
> >
> > need to compile with -fgimple to have the attribute not ignored.  And yes,
> > a 8-bit precision signed bool is a thing then (but still [-1,0]).
>
> What should _Widthof() return for such types?  1?  8?
> <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3573.txt>

What does _Widthof do to struct { int i : 3; } a.i?  Hmm.

struct { long long x : 37; } x;
int main()
{
  __typeof (x.x) a;
}

t4.c:4:13: error: ‘typeof’ applied to a bit-field
    4 |   __typeof (x.x) a;
      |             ^

I see.  In GNU C this has long long : 37 type (it isn't promoted).
But this works ;)
(by accident?)

struct { long long x : 37; } x;
int main()
{
  auto b = x.x;
  __typeof (b) c;
  return c;
}

> cat t4.c.006t.original

;; Function main (null)
;; enabled by -tree-original


{
  <unnamed-signed:37> b = x.x;
  <unnamed-signed:37> c;

    <unnamed-signed:37> b = x.x;
    <unnamed-signed:37> c;



>
> Have a lovely day!
> Alex
>
> >
> > Richard.
>
> --
> <https://www.alejandro-colomar.es>
> Use port 80 (that is, <...:80/>).

Reply via email to