Many thanks, I tested your fix but I still have a broken case: int main() { unsigned int x = 0xffffffff; unsigned int y = 1;
printf("fixed %08x\n", x >> y); printf("fixed %08x\n", (~(unsigned int)0) >> (unsigned int)1); printf("fails %08x\n", (~0) >> 1); } Christian -----Original Message----- From: tinycc-devel-bounces+eligis=wanadoo...@nongnu.org [mailto:tinycc-devel-bounces+eligis=wanadoo...@nongnu.org] On Behalf Of grischka Sent: Tuesday, December 30, 2008 15:35 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] wrong preprocessor shift operation Christian Jullien wrote: > I think you're right. > Bug occurs when int (0xffffffff) is promoted to long long > (0xffffffffffffffff). Then right shift and back to int conversion returns a > false result. > Another possible fix is to cast to (unsigned int) as with > > if (t1 == VT_LLONG) { > l1 = v1->c.ll; > } else { > l1 = (unsigned int)v1->c.i; > } > > For my test case it works but will probably break many things. > > As professional software developer I know how long it takes to test > everything after a fix. This fix can break many things and I don't want > (have to time) to become a TinyCC maintainer. > > I think that long long computation/promotion should only occur when type is > declared as long long. > > I let you decide how you want to address this bug. Well, then thanks for reporting. I pushed a fix on the mob branch. http://repo.or.cz/w/tinycc.git?a=commitdiff;h=1fe4008fa3472ad0ae23f3901b64f9 995a08952d _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/tinycc-devel ---------------------------------------------------------------------------- ----------- Orange vous informe que cet e-mail a ete controle par l'anti-virus mail. Aucun virus connu a ce jour par nos services n'a ete detecte. _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/tinycc-devel