Hello, thanks for you mail. You are right my plugin returns a 'false' warning on your case. That should be possible to handle this case but it needs some search: when parsing func,we should request to look at the Guard constructor (either by inserting a new pass or maybe by using LTO (but I should look deeper at this)) to check if there is a test or no.
For the moment my plugin's 'view' is limited to a single function but that should be something to improve. Pierre Vittet On 12/08/2011 18:00, Jonathan Wakely wrote: > On 12 August 2011 15:54, Pierre Vittet wrote: >> >> For the moment, the plugin has only be tested on C code, this might >> works with only few changes for C++. > > Would your example tests for grub warn about the following C++ code? > > struct Guard { > Guard(void* p) : p(p) { if (!p) throw std::bad_alloc(); } > ~Guard() { grub_free(p); } > void* p; > }; > > void func(grub_size_t n) > { > Guard g(grub_malloc(n)); > // do something with g.p > } > > For it to be useful for C++ it would be necessary to not warn about that code. >