tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tiny bit of lint


From: Larry Doolittle
Subject: Re: [Tinycc-devel] tiny bit of lint
Date: Tue, 9 May 2017 07:23:39 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

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:address@hidden
> On Behalf Of grischka
> Sent: mardi 9 mai 2017 10:26
> To: address@hidden
> 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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> 
> 
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]