[squid-dev] [PATCH] Bug 4438 - string pool refactoring

Alex Rousskov rousskov at measurement-factory.com
Thu Mar 31 16:14:25 UTC 2016


On 03/31/2016 04:13 AM, Amos Jeffries wrote:
> On 31/03/2016 7:29 a.m., Alex Rousskov wrote:
>> On 03/30/2016 11:15 AM, Amos Jeffries wrote:
>>> On 30/03/2016 8:19 a.m., Alex Rousskov wrote:
>>>> This committed code does nothing useful: Static variables, such as
>>>> "pools" are zero-initialized by default and that happens at constant
>>>> initialization time.
>>
>>
>>> Not necessarily. That is OS and allocator library dependent behaviour.
>>
>> It is guaranteed by the C++ standard. See the "Static initialization"
>> section at http://en.cppreference.com/w/cpp/language/initialization

Since this is a local variable, a better reference is actually

http://en.cppreference.com/w/cpp/language/zero_initialization

as referenced by
http://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables


> Okay. But forgive me for not trusting to that. I've left the pointers
> being zeroed explicitly for now.

Your trust in cppreference.com or lack of thereof is not an issue here.
It is your responsibility to justify the code you add, especially when
the code goes against well-known idioms such as "statics are
zero-initialized".

AFAICT, there is currently insufficient justification for adding that
memset(). You said your compiler warns if memset() is not there. If you
provide the exact code snippet and the compiler name/version/options
that result in a warning, then it would become my responsibility to find
a flaw in that evidence or in my thinking.

As always, this single line is of low importance, but it becomes a
bigger problem when others start copying bogus code and/or fail to find
[simple] solutions because they think such complex code is needed.


I also disagree with the rest of your "this old code does not matter
enough to fix it" arguments, but I have no time and hope left to
convince you otherwise.

Alex.



More information about the squid-dev mailing list