问题描述
我对这种诊断的益处有疑问.
一位用户建议我们实施所有显式类型的搜索
在PVS-Studio分析仪中以C样式进行转换.
即是一种诊断程序,用于检测此类构造:
int * x =( int *)y; float a = float (b); 浮动 c =(浮动)(d);
其目的是将所有这些转换替换为更安全的
版本-reinterpret_cast/static_cast/const_cast.在此过程中
这样的重构,很可能会检测到代码中的某些缺陷.
当然,这不是检测关键错误,如果我们
实施此诊断,它将在[客户的
"部分中特定请求],默认情况下处于禁用状态.
但是我什至怀疑这种诊断的好处.所以我决定问
其他用户:是否有人需要此选项来搜索显式
C风格的类型转换?任何人都想表演这种
I have a question concerning the benefit of this diagnostic.
One user suggested that we implemented search of all the explicit type
conversions in C style in the PVS-Studio analyzer.
That is, a diagnostic to detect constructs of this kind:
int *x = (int *)y; float a = float(b); float c = (float)(d);
Its purpose is to replace all these conversions with their safer
versions - reinterpret_cast/static_cast/const_cast. During the process
of such refactoring, some defects in code may well be detected.
Of course, this is not detection of crucial errors, and if we
implement this diagnostic, it will be in the section [Customer''s
Specific Requests] and disabled by default.
But I even doubt the benefit of this diagnostic. So I decided to ask
other users: does anybody else need this option of searching for explicit
type conversions in C style? Would anybody like to perform this kind
of refactoring in their code?
这篇关于搜索C风格的显式类型转换:a =(int)b;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!