A number of static analysis errors in 5.5.4

When running static analysis with the command `Engine\Build\BatchFiles\Build.bat <project> Win64 Shipping -DisableUnity -Define:UE_CHECK_DISABLE_OPTIMIZATION=1 -WarningsAsErrors -StaticAnalyzer=Default`, we’re seeing a number of flagged lines in the engine now that we’ve upgraded to 5.5.4.

Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\PerParticlePBDCollisionConstraint.h(82): error C2220: the following warning is treated as an error Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\PerParticlePBDCollisionConstraint.h(67) : warning C6239: (<non-zero constant> && <expression>) always evaluates to the result of <expression>: Did you intend to use the bitwise-and (&) operator? If not, consider removing the redundant '<non-zero constant>' and the &&` operator.

Engine\Source\Runtime\Experimental\Iris\Core\Private\Iris\ReplicationSystem\Filtering\ReplicationFiltering.cpp(1096): error C2220: the following warning is treated as an error
Engine\Source\Runtime\Experimental\Iris\Core\Private\Iris\ReplicationSystem\Filtering\ReplicationFiltering.cpp(1091) : warning C6011: Dereferencing NULL pointer ‘DynamicFilteredOutObjects’. : Lines: 904, 905, 911, 913, 914, 916, 917, 918, 919, 920, 922, 923, 925, 927, 928, 929, 930, 931, 934, 937, 938, 939, 925, 944, 951, 952, 953, 954, 955, 957, 958, 959, 962, 963, 964, 967, 968, 969, 988, 991, 995, 955, 1056, 1058, 1061, 1062, 1063, 1064, 1065, 1066, 1068, 1070, 1072, 1073, 1074, 1076, 1077, 1079, 1080, 1082, 1083, 1086, 1089, 1091
Engine\Source\Runtime\Experimental\Iris\Core\Private\Iris\ReplicationSystem\Filtering\ReplicationFiltering.cpp(1092) : warning C6011: Dereferencing NULL pointer ‘DynamicFilteredOutObjectsHysteresisAdjusted’. : Lines: 904, 905, 911, 913, 914, 916, 917, 918, 919, 920, 922, 923, 925, 927, 928, 929, 930, 931, 934, 937, 938, 939, 925, 944, 951, 952, 953, 954, 955, 957, 958, 959, 962, 963, 964, 967, 968, 969, 988, 991, 995, 955, 1056, 1058, 1061, 1062, 1063, 1064, 1065, 1066, 1068, 1070, 1072, 1073, 1074, 1076, 1077, 1079, 1080, 1082, 1083, 1086, 1089, 1091, 1092

Engine\Source\Runtime\Experimental\Chaos\Private\Chaos\VelocityField.cpp(796): error C2220: the following warning is treated as an error
Engine\Source\Runtime\Experimental\Chaos\Private\Chaos\VelocityField.cpp(603) : warning C6239: ( && ) always evaluates to the result of : Did you intend to use the bitwise-and (&) operator? If not, consider removing the redundant ‘’ and the && operator.
Engine\Source\Runtime\Experimental\Chaos\Private\Chaos\VelocityField.cpp(690) : warning C6239: ( && ) always evaluates to the result of : Did you intend to use the bitwise-and (&) operator? If not, consider removing the redundant ‘’ and the && operator.

Engine\Source\Runtime\RHI\Private\RHICommandList.cpp(240): error C2065: ‘AllowedPipelines’: undeclared identifier
Engine\Source\Runtime\RHI\Private\RHIResources.cpp(36): error C2065: ‘CurrentlyDeleting’: undeclared identifier
Engine\Source\Runtime\RHI\Private\RHIResources.cpp(73): error C2065: ‘CurrentlyDeleting’: undeclared identifier

Engine\Source\Runtime\RenderCore\Private\RenderGraphPrivate.h(221): error C2220: the following warning is treated as an error
Engine\Source\Runtime\RenderCore\Private\RenderGraphPrivate.h(215) : warning C6239: ( && ) always evaluates to the result of : Did you intend to use the bitwise-and (&) operator? If not, consider removing the redundant ‘’ and the && operator.`We have our build machine running static analysis nightly and it only started catching these after we upgraded to 5.5.4 (our 5.4.2 engine had none of these, so they’re either regressions or something changed in the static analysis capabilities that now flags these as issues).

We can attempt to band-aid fix these locally in the short term, but wanted to make sure that you all are aware that they’re present.

Steps to Reproduce
Run `Engine\Build\BatchFiles\Build.bat <project> Win64 Shipping -DisableUnity -Define:UE_CHECK_DISABLE_OPTIMIZATION=1 -WarningsAsErrors -StaticAnalyzer=Default`

Hi Andrew,

We are only running Static Analysis on the Development builds here. The main reason is that the Shipping target is assuming that the process is in the correct state for faster execution and we would not want to care for some of the reported warnings. Most of the warnings that you shared are actually false-positives or will have no impact at runtime as they will be optimized out.

The recommendation would be to run with -StaticAnalyzerProjectOnly when running on the Shipping target.

Regards,

Martin

I see. In that case we will probably only run full static analysis on our development builds and use -StaticAnalyzerProjectOnly as you mentioned when we do our shipping builds.

Thanks.