Larry, Don't you think we can afford 11/20 bytes and increase readability instead of this obfuscated code?
printf("<- %s (%d symbol%s)\n", buf, sym_count, &"s"[sym_count < 2]); If you want to save bytes, you can just printf("<- %s (%d symbol[s])\n", buf, sym_count); Which is both faster and shorter. -----Original Message----- From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of Larry Doolittle Sent: mardi 9 mai 2017 16:24 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] tiny bit of lint Friends - On Tue, May 09, 2017 at 11:49:23AM +0200, Christian Jullien wrote: > Arf! You're right. > That why I never fix warning in a code which is not mine. > My fix proposal is definitively better. Sorry, everyone, testing should have caught my original mistake. I committed a fix. The real equivalence is between the original "s" + (i<2) and &"s"[i<2]. ((i > 1) ? "s" : "") as suggested by Christian is perhaps easier to for humans to understand, but (at least when compiling with tcc) produces larger (by 20 bytes) and slower object code. With gcc -O2 the object code size penalty is 11 bytes. This is on x86_64, YMMV. With that extra &, I can't really say the looks are improved over the original. But testing with gcc (4.9.2), tcc, and clang (3.5.0) they all get the right answer on both styles, and clang complains about the original form. - Larry > -----Original Message----- > From: Tinycc-devel > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] > On Behalf Of grischka > Sent: mardi 9 mai 2017 10:26 > To: tinycc-devel@nongnu.org > Subject: Re: [Tinycc-devel] tiny bit of lint > > Larry Doolittle wrote: > > @@ -965,7 +965,7 @@ static void pe_build_exports(struct pe_info *pe) > } else { > fprintf(op, "LIBRARY %s\n\nEXPORTS\n", dllname); > if (pe->s1->verbose) > - printf("<- %s (%d symbol%s)\n", buf, sym_count, "s" + > (sym_count < 2)); > + printf("<- %s (%d symbol%s)\n", buf, sym_count, > + "s"[sym_count < > 2]); > } > #endif > > And that is wrong of course. > > $ tcc examples/dll.c -shared -v > ---> crash > > -- gr > > _______________________________________________ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel > > > _______________________________________________ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel