On Sun, 1 May 2022, adr wrote:

Yeah, i was thinking
  int -> long -> vlong -> uvlong

No, it was a mistake, I forgot to check again that the conversion to
unsigned when the constant is using the sign bit doesn't occurs to
decimal constants.

Also, reading 9front's mailing list I noticed the mess ignoring
that convvtox will return vlong, type casting should do the trick:

[...]
       vv = yylval.vval;
       if(c1 & Numvlong ||
         (uvlong)convvtox(vv, TUVLONG) > convvtox(vv, TULONG) ||
         (c1 & (Numdec|Numuns)) == Numdec && convvtox(vv, TLONG) < 0) {
               if((c1 & Numuns) || convvtox(vv, TVLONG) < 0 && (c1 & Numdec) == 
0) {
                       c = LUVLCONST;
                       t = TUVLONG;
                       goto nret;
               }
               c = LVLCONST;
               t = TVLONG;
               goto nret;
       }
       if(c1 & Numlong ||
         convvtox(vv, TULONG) > convvtox(vv, TUINT) ||
         (c1 & (Numdec|Numuns)) == Numdec && convvtox(vv, TINT) < 0) {
               if((c1 & Numuns) || convvtox(vv, TLONG) < 0 && (c1 & Numdec) == 
0) {
                       c = LULCONST;
                       t = TULONG;
                       goto nret;
               }
               c = LLCONST;
               t = TLONG;
               goto nret;
       }
       if((c1 & Numuns) || convvtox(vv, TINT) < 0 && (c1 & Numdec) == 0) {
               c = LUCONST;
               t = TUINT;
               goto nret;
       }
       c = LCONST;
       t = TINT;
       goto nret;
[...]

It looks complex at first, but each line is telling you the reason
to expand the constant, and when to use unsigned types first. For
me is absolutely better than insert size assumptions in a piece of
code which is making a great effort to let that to machine dependent
code well kept in another place.

I'll make some tests.

adr

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T22754f10b241991c-M64323f2f5a4e8db8ea11250b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to