Hi Richard,

On Thu, Oct 16, 2025 at 02:15:59PM +0200, Alejandro Colomar wrote:
> On Thu, Oct 16, 2025 at 01:41:40PM +0200, Richard Biener wrote:
> > > > 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.
> 
> _Widthof() is a constraint violation with non-integer types.
> 
> (And I think I should restrict it to reject booleans too, precisely
>  because it's not obvious what it should return.)

Ahh, sorry; I misunderstood.  You mean _Widthof() of the bit-field
member.  _Widthof of a bit-field should return the number of bits in the
bit field.  That is...

> 
> 
> Have a lovely day!
> Alex
> 
> > struct { long long x : 37; } x;
> > int main()
> > {
> >   __typeof (x.x) a;

..., _Widthof(x.x) == 37


Cheers,
Alex

> > }
> > 
> > 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;

Nice!  :)

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).

Attachment: signature.asc
Description: PGP signature

Reply via email to