(original) (raw)

What does "have no effect" mean in this case? In my mind, there are many casts that have no effect - other than allowing the code to compile, which is quite an important effect in itself (e.g. casting a 32-bit unsigned to a pointer on your typical 32-bit system).

Are you seeking to warn for:

int a;
int b;

a = (int) b;

and similar things?

--
Mats

On 9 April 2017 at 20:35, Craig Topper via llvm-dev <llvm-dev@lists.llvm.org> wrote:
This is question is probably better on the clang cfe-dev list.

On Sun, Apr 9, 2017 at 12:01 PM Brennan Vincent via llvm-dev <llvm-dev@lists.llvm.org> wrote:
How difficult would it be to add a warning to Clang when the programmer
performs a cast that provably has no effect?

A particular case I have in mind is someone getting confused and calling
std::move on an argument to a copy-constructor for a class that doesn't
implement move semantics.

I would be grateful if someone either (1) told me why this is
difficult/impossible, or (2) gave me some pointers to where I could
start trying to implement it...
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
LLVM Developers mailing list
llvm-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
\~Craig

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
LLVM Developers mailing list
llvm-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev