Is there a way to make a compiler (clang ++ or g ++) to report the following situations:
static_assert(!std::is_lvalue_reference< T >::value); void g(T); void f(T x) { T y = x; #if 0
or
static_assert(!std::is_reference< T >::value); T f() { T x; T y = x; #if 0
Another warning class must be activated when moving from a variable again:
void f() { T x; T y = std::move(x); T z = x;
Variables of non- std::unique_ptr classes such as std::unique_ptr rarely reused after their contents have been stolen.
It would be great if the warnings described above were available as a variable called through #pragma or an attribute, or globally for all variables that are classes with a user-defined operator and an assignment constructor.
It is sometimes difficult to track the lifetime of a variable.
There is an SSA form (a static form of single assignment) of an intermediate representation (for example, AST) used in modern compilers. Therefore, I believe that it is not so difficult for compilers to detect the above situations.
c ++ c ++ 11 move-semantics warnings
Orient
source share