[cfe-dev] Question regarding -Wlifetime

Paulo Pinto via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 5 02:09:58 PDT 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191005/0fc33951/attachment.html>


More information about the cfe-dev mailing list