You are right that the warning is wrong in the case that both are zero, I'm
not sure if this is still the case in newer gcc versions
since I only tried 4.8.*. I'm okay with keeping my local patch to disable
the warning in my case and I can fully understand that
adding a not necessary test to remove a false warning would harm
performance.

2015-08-20 19:05 GMT+02:00 Scott Robison <scott at casaderobison.com>:

> On Thu, Aug 20, 2015 at 10:46 AM, Scott Doctor <scott at scottdoctor.com>
> wrote:
>
> > My opinion is to keep it portable. The warning is there for a reason. you
> > are worried about performance yet are calling a function that does
> nothing,
> > which will take more memory cycles than a simple check for zero.
> >
>
> I didn't say don't make a change. I'm observing there are things to
> consider. In particular the optimization strategies that the SQLite team
> have pursued for several years now have been *tiny* little optimizations
> that would never be justifiable on their own but that really add up,
> particularly for small devices probably running on batteries.
>
>
> > Trying to memset a zero length is a bug, not the warning. Add an if
> > statement around it. If the variable is local, it will probably be
> > optimized as a register variable and a zero check of a register is a
> single
> > op-code.
> >
>
> Trying to memset a zero length buffer is not a bug if the length of the
> sequence of bytes that needs to be set is zero. C89 in particular does not
> disallow this use.
>
>
> > the problem with disabling warnings is that even if this instance is not
> > an error, some other part of the code may end up with the same situation
> > but is an error in the coding. I would prefer code that can be compiled
> > with all warnings turned on that gives no warnings than have a potential
> > problem because of a glitch in the code.
> >
>
> I don't think anyone called for disabling the warning. I think it should
> just be ignored in this case, just as I ignore warnings that are generated
> by Visual C++ when I compile SQLite there.
>
> --
> Scott Robison
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to