[AGENT++] src/asn1.cpp:386:5: error: ISO C++17 does not allow 'register' storage class specifier
Frank Fock
fock at agentpp.com
Thu Sep 6 00:33:53 CEST 2018
Hi All,
I do not know which code you are quoting, but it is not the latest SNMP++ version. It has not “register” modifier in any variable definition.
In addition, the memory allocation issues are caused by the Openssl version you are using or send the Openssl team . Maybe you should upgrade this library?
From my point of view it is not helpful to criticise historic or self modified code.
Analysing false alarms is more work than you might think and the time it consumes
blocks us from actually improving the source code.
Any bug report is welcome, but a minimum of quality check should be done be the reporter (and commenter) beforehand.
Best regards,
Frank
> On 4. Sep 2018, at 08:59, Isaac Nickaein <nickaein.i at gmail.com> wrote:
>
>> I have problems to compile snmp++ with newer clang++ compiler
>> ../../src/asn1.cpp:386:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
>> register int header_len;
>> ^~~~~~~~~
>> 1 error generated.
>
> I suggest removing the `register` keyword.
>
> Historically, It has been used to hint the compiler to allocate a CPU
> register for this variable, but today compilers ignore it and have an
> optimization step which make these decisions.
>
> Article by Herb Sutter:
> http://www.drdobbs.com/184403859
> search for "CPU" in which concludes:
> "Never write register. It's exactly as meaningful as whitespace"
>
> More discussion on this:
> https://stackoverflow.com/questions/3207018
>
>>
>> There are also cppcheck serious warnings:
>>
>> src/auth_priv.cpp:2046:0: warning: Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'. [useAutoPointerArray]
>> std::auto_ptr<unsigned char> ipad(new unsigned char[block_size]);
>> ^
>> src/auth_priv.cpp:2047:0: warning: Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'. [useAutoPointerArray]
>> std::auto_ptr<unsigned char> opad(new unsigned char[block_size]);
>> ^
>
> This seems to be a misuse of auto_ptr with array. auto_ptr always call
> `delete` for freeing memory which is not suitable for arrays (delete[]
> must be called instead).
> More info: https://stackoverflow.com/questions/6520844
>
> How about using std::vector?
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> https://oosnmp.net/mailman/listinfo/agentpp
More information about the AGENTPP
mailing list