On Fri, Oct 6, 2017 at 11:04 AM Roy Marples <r...@marples.name> wrote:

> On 05/10/2017 23:14, Kevin Lyda wrote:
> > That's not actually correct in practice.
> And top posting is?
>

Yes. It is. We lost that battle, sorry. If it worries you, t-prot is a
thing.

Interesting that you assume I use bash and gcc.
> This is more portable.
> for f in foo bar; do cc -S $f.c; done
>

I use zsh actually, and you figured out what I meant. Neither version will
work in csh style shells. And an odd complaint about a shortcut here, since
later you claim more text makes it harder to read. Also I specified gcc
specifically because I had only tested with gcc - though from past
experience I know modern compilers like clang, icc and others also do such
optimisation.

Also you removed the -O2 that I had in there.


> Now, if I do apply -O2 then clang (my system compiler) does indeed
> optimise it away.
> What is worring is that even with -O0 or no -O gcc *always* optimises it
> away. What if I want to call the function to be called regardless?
>

Ugh, and my tests with gcc -O0 were actually with clang because Apple links
gcc to clang. Checking gcc -O0 on Linux shows that it does optimize even at
-O2.

Right, so to get foo.c to actually call strlen with gcc:

gcc -fno-builtin-strlen -S foo.c

or more generically:

gcc -fno-builtin -S foo.c


> Spoken like a man who has never dealt with compiler issues!
>

A rather funny comment since I'm currently dealing with multiple compiler
issues.

if (strlen(foo) != 0)
> if the function to calculate the length of the string is not zero
>
> if (*foo != '\0')
> if the first character of the string is not NUL
>
> I'm having a hard time beliving that the former is more readable AND
> just as performant.
> It has more text for the brain to digest and a man page to read per
> platform.
>

Where "more text" is four characters and replaces symbols for words that
are easy for the eye to skim. Maybe I've lead a sheltered career for the
past three decades, but I don't really recall a lot of APL shops in my
travels.

Or are you going to assume that gcc is the only compiler ever used anywhere?
>

Nope. Never do. Though I do like it a great deal more than VMS's C
compiler. I do wish Apple wouldn't point gcc at clang though.

Regardless, the dnsmasq Makefile sets -O2 in its CFLAGS so gcc or clang or,
as I said previously, any modern C compiler, it will optimise out the
strlen call and the strlen call is easier to read.

Kevin
_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to