[cfe-dev] Question regarding -Wlifetime

Paulo Pinto via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 5 10:53:59 PDT 2019


Hi Gabor,

thanks for the clarification.

I just got curious after the CppCon talk and wanted to check out the 
current state.

Cheers,
Paulo

Am 05.10.2019 um 11:22 schrieb Gábor Horváth:
> Hi Paulo,
>
> The -Wlifetime analysis is not part of mainline clang yet (only the 
> statement-local warnings). If you have some questions, concerns 
> regarding the flow-sensitive analysis feel free to open a ticket at 
> https://github.com/mgehre/llvm-project
>
> Currently, the flow-sensitive lifetime analysis does not check for 
> memory leaks. If you want to find leaks statically, you could try out 
> the Clang Static Analyzer (https://clang-analyzer.llvm.org/) which has 
> some great checks to find such issues.
>
> Cheers,
> Gabor
>
> On Sat, 5 Oct 2019 at 11:10, Paulo Pinto via cfe-dev 
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>
>     Hi everyone,
>
>     just decided to start playing around with -Wlifetime on Godbolt,
>     and came up with
>     an example that failed to meet my expectations, namely:
>
>     char*leak()
>     {
>     returnnewchar;
>     }
>
>     intmain()
>     {
>     char*ch = leak();
>     }
>
>     Shouldn't the lifetime static analyser complain that ch on main()
>     leaks, or am I expecting too much from the analyser?
>
>     Initially I though that by using main(), the analyser just assumed
>     it would be released anyway, but renaming it to something
>     else, still doesn't trigger a leak warning.
>
>     Thanks in advance,
>     Paulo
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191005/a945f1a2/attachment.html>


More information about the cfe-dev mailing list