+cfe-dev

Hi Andrea,

I think you might get more luck asking on the cfe-dev mailing list.

George

> On May 15, 2018, at 1:15 PM, Andrea Arteaga via cfe-users 
> <cfe-users@lists.llvm.org> wrote:
> 
> Dear all,
> Recently, my team suffered from a bug due to a double bad usage of C++.
> 
> We have a function returning a reference to an object:
> 
>     Object& GetObject();
> 
> Sometimes we use this function like this:
> 
>     auto obj = GetObject();
> 
> This triggers a copy of the object, which we really don't mean. The two 
> problems are:
> 1. Object does not delete the copy constructor, nor does it declare one. We 
> have a policy of never using implicitly-declared constructors, we either use 
> `=delete` or `=default`. Nevertheless we missed this class.
> 2. A reference is demoted to a rvalue due to the usage of `auto` instead of 
> `auto&`.
> 
> We would like clang to issue warnings in these two cases. The latter case 
> does not really seem easy to warn about, but the former looks straightforward.
> 
> Does clang offer such warnings?
> 
> Thanks
> Andrea Arteaga 
> 
> _______________________________________________
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to