How to try out -Wlifetime ?


I watched Herb's talk on Cppcon so I decided to try out the new lifetime feature. I cloned llvm and clang master from github mirror and built both locally.

I tried to compile the first godbolt sample ( but no luck:

clang -Wlifetime -lstdc++ b.cpp
warning: unknown warning option '-Wlifetime'; did you mean '-Wdate-time'? [-Wunknown-warning-option]
1 warning generated.

What am I doing wrong?


you can try it out on ``, as there is a custom built there.

If you want to build yourself you should use
`` (lifetime-branch) as the patches are
not upstreamed (yet).

Best, Jonas

Thanks for the tip, I got it up and running.

I am trying -Wlifetime on some decade old projects that were ported from C to C++ just to see how bad things are and what are some common mistakes. Is it possible to suppress some subset of warnings such as -Wlifetime-pointer-arithmetic (it clutters the output way too much and I am not interested in this specific warning)? Possibly as a compiler flag and not a pragma.

I also managed to segfault clang itself on one project, I guess I should report that to the github fork page.

Best regards,