catching 32/64 bit integer mixing

2020-05-23 Thread Drew Parsons
An upstream author has asked whether we know of tools or compiler flags to help catch problems mixing 64 and 32 bit integers, for instance catching implicit conversions, as in int64_t n = ...; for (int32_t i=0; iThere is -fsanitize=signed-integer-overflow (which generates a runtime error m

Re: catching 32/64 bit integer mixing

2020-05-23 Thread Thomas Schiex
For open source projects, a few online static analyzers are available and usable for free. This kind of integer type mismach will be caught by most of them. Possibly clang-static-analyzer will do the job. Otherwise, an easy one is lgtm for example. See https://lgtm.com/ (I

Re: catching 32/64 bit integer mixing

2020-05-23 Thread Drew Parsons
Thanks Thomas, I'll pass that on. Drew On 2020-05-23 21:33, Thomas Schiex wrote: For open source projects, a few online static analyzers are available and usable for free. This kind of integer type mismach will be caught by most of them. Possibly clang-static-analyzer will do the job. Otherwis

Re: catching 32/64 bit integer mixing

2020-05-26 Thread Drew Parsons
Hi again Thomas, upstream says they've looked at clang-static-analyzer, but it'll be nontrivial to implement. Not entirely obvious how to proceed with lgtm either, it only comes with simple examples. If you (or anyone else) has time to work on this, they'd sure appreciate a helping hand. Thi

Re: catching 32/64 bit integer mixing

2020-05-27 Thread Thomas Schiex
Hello Drew, I have used LGTM for one of my open source projects. If the sources are deposited on GitHub (or Gitlab) for example, this is immediate to use: create an account under lgtm.com, create a project and point it to the git repo. It will fetch sources and start the analysis. The results take

Re: catching 32/64 bit integer mixing

2020-05-27 Thread Drew Parsons
Thanks again, Thomas. Upstream is on gitlab and already runs CI testing, so sounds like lgtm ought to work for them. I'll point them at this message thread for details. Drew On 2020-05-27 16:19, Thomas Schiex wrote: Hello Drew, I have used LGTM for one of my open source projects. If the s

Re: catching 32/64 bit integer mixing

2020-12-29 Thread Florian Weimer
* Drew Parsons: > An upstream author has asked whether we know of tools or compiler flags > to help catch problems mixing 64 and 32 bit integers, for instance > catching implicit conversions, as in > >int64_t n = ...; >for (int32_t i=0; i ... >} > > There is -fsanitize=signed-in