[GiNaC-list] [cppcheck] found a few issues

Alexei Sheplyakov alexei.sheplyakov at gmail.com
Mon May 17 18:12:57 CEST 2010


Hi,

On Thu, May 13, 2010 at 11:49:33PM +0200, Martin Ettl wrote:
 
> i have checked the source of the current git head from ginac with the static
> code analysis tool cppcheck (http://sourceforge.net/projects/cppcheck/).
> It found a few uninitialized variables, const correctness issues...

Actually the only relevant warning is:

> [../ginac/excompiler.cpp:175]: (Error) Dangerous iterator usage. After erase the iterator is invalid so dereferencing it or comparing it with another iterator is invalid.

The rest are not very useful.

> [exam_cra.cpp:85]: (Style) Function parameter 'ntimes' is passed by value. It could be passed by reference instead.

Huh? Any decent optimizer will convert that back into pass-by-value (since
the value fits into a register).

> [../ginac/basic.h:112]: (Style) Member variable not initialized in the constructor 'basic::hashvalue'

gethash() checks object flags to figure out if hashvalue needs to be
(re)computed, and (re)calculates it if necessary. Hence initializing
it in the constructor (presumably with some dummy value) is not really
useful.

> [../ginac/expairseq.cpp:1291]: (Style) Variable 'erased' is assigned a value that is never used

That value is used when assertions are enabled.


Best regards,
	Alexei



More information about the GiNaC-list mailing list