Skip to main content

Open Catalog of Code Guidelines for Correctness, Modernization, Security, Portability, and Optimization

About​

This Open Catalog is a collaborative effort to consolidate expert knowledge on code guidelines for the correctness, modernization, security, portability, and optimization of code written in C, C++, and Fortran programming languages. The Catalog consists of a comprehensive set of checks (rules) that describe specific issues in the source code and provide guidance on corrective actions, along with extensive documentation, example codes and references to additional reading resources.

Benchmarks​

The Open Catalog includes a suite of microbenchmarks designed to demonstrate:

  • No performance degradation when implementing the correctness, modernization, security, and portability recommendations.
  • Potential performance enhancements achievable through the optimization recommendations.

Checks​

IDTitleCategoryCWEISO/IEC 24772-8SEI CERT CSEI CERT C++CFortranC++AutoFix
PWR001Pass global variables as function argumentscorrectness, modernization, securityCWE-1108DCL19-C✓✓✓
PWR002Declare scalar variables in the smallest possible scopecorrectness, modernization, securityCWE-1126DCL19-C✓✓
PWR003Explicitly declare pure functionsmodernization, security6.24, 6.32✓✓✓
PWR004Declare OpenMP scoping for all variablescorrectness, security✓✓✓
PWR005Disable default OpenMP scopingcorrectness, security✓✓✓
PWR006Avoid privatization of read-only variablesoptimization✓✓✓
PWR007Disable the implicit declaration of variables and procedurescorrectness, modernization, securityCWE-6286.17, 6.18, 6.19, 6.21, 6.54, 7.2DCL07-C, DCL31-C, EXP37-C✓✓1
PWR008Declare the intent for each procedure argumentcorrectness, modernization, securityCWE-3746.32, 6.65DCL13-C✓✓1
PWR009Use OpenMP teams to offload work to GPUoptimization✓✓✓
PWR012Pass only required fields from derived type as arguments to minimize data movementsoptimization✓✓✓
PWR013Avoid copying unused variables to or from the GPUoptimization✓✓✓
PWR014Out-of-dimension-bounds matrix accesscorrectness, securityCWE-125, CWE-7876.8, 6.9, 6.10ARR30-C✓✓
PWR015Avoid copying unnecessary array elements to or from the GPUoptimization✓✓✓
PWR016Use separate arrays instead of an Array-of-Structsoptimization✓✓✓
PWR017Using countable while loops instead of for loops may inhibit vectorizationoptimization✓✓
PWR018Call to recursive function within a loop inhibits vectorizationoptimization✓✓✓
PWR019Consider interchanging loops to favor vectorization by maximizing inner loop's trip countoptimization✓✓✓
PWR020Consider loop fission to enable vectorizationoptimization✓✓✓
PWR021Consider loop fission with scalar to vector promotion to enable vectorizationoptimization✓✓✓
PWR022Move invariant conditional out of the loop to facilitate vectorizationoptimization✓✓✓
PWR023Add 'restrict' for pointer function arguments to hint the compiler that vectorization is safeoptimization✓✓
PWR024Loop can be rewritten in OpenMP canonical formoptimization✓✓
PWR025Consider annotating pure function with OpenMP 'declare simd'optimization✓✓✓
PWR026Annotate function for OpenMP Offloadoptimization✓✓✓
PWR027Annotate function for OpenACC Offloadoptimization✓✓✓
PWR028Remove pointer increment preventing performance optimizationoptimization✓✓
PWR029Remove integer increment preventing performance optimizationoptimization✓✓✓
PWR030Remove pointer assignment preventing performance optimization for perfectly nested loopsoptimization✓✓✓
PWR031Replace pow by multiplication, division and/or square rootoptimization✓✓✓
PWR032Avoid calls to mathematical functions with higher precision than requiredoptimization✓✓
PWR034Avoid strided array access to improve performanceoptimization✓✓✓
PWR035Avoid non-consecutive array access to improve performanceoptimization✓✓✓
PWR036Avoid indirect array access to improve performanceoptimization✓✓✓
PWR037Potential precision loss in call to mathematical functioncorrectness, securityCWE-1976.2, 6.6FLP34-C✓✓
PWR039Consider loop interchange to improve the locality of reference and enable vectorizationoptimization✓✓✓✓1
PWR040Consider loop tiling to improve the locality of referenceoptimization✓✓✓
PWR042Consider loop interchange by promoting the scalar reduction variable to an arrayoptimization✓✓✓
PWR043Consider loop interchange by replacing the scalar reduction valueoptimization✓✓✓
PWR044Avoid unnecessary floating-point data conversions involving constantsoptimization✓✓
PWR045Replace division with a multiplication with a reciprocaloptimization✓✓
PWR046Replace two divisions with a division and a multiplicationoptimization✓✓✓
PWR048Replace multiplication/addition combo with an explicit call to fused multiply-addoptimization✓✓
PWR049Move iterator-dependent condition outside of the loopoptimization✓✓✓
PWR050Consider applying multithreading parallelism to forall loopoptimization✓✓✓✓1
PWR051Consider applying multithreading parallelism to scalar reduction loopoptimization✓✓✓✓1
PWR052Consider applying multithreading parallelism to sparse reduction loopoptimization✓✓✓✓1
PWR053Consider applying vectorization to forall loopoptimization✓✓✓✓1
PWR054Consider applying vectorization to scalar reduction loopoptimization✓✓✓✓1
PWR055Consider applying offloading parallelism to forall loopoptimization✓✓✓✓1
PWR056Consider applying offloading parallelism to scalar reduction loopoptimization✓✓✓✓1
PWR057Consider applying offloading parallelism to sparse reduction loopoptimization✓✓✓✓1
PWR060Consider loop fission to separate gather memory access patternoptimization✓✓✓
PWR062Consider loop interchange by removing accumulation on array valueoptimization✓✓✓
PWR063Avoid using legacy Fortran constructscorrectness, modernization, securityCWE-477, CWE-1075, CWE-11196.27, 6.28, 6.31, 6.54, 6.58✓
PWR064PWR064: Precision loss in floating-point constantcorrectness, securityCWE-1976.2, 6.6FLP34-C✓
PWR068Call procedures through explicit interfaces, preferably as module procedurescorrectness, modernization, securityCWE-6286.8, 6.9, 6.10, 6.11, 6.32, 6.34, 6.53DCL07-C, DCL31-C, EXP37-C✓
PWR069Use the keyword only to explicitly state what to import from a modulecorrectness, modernization, security6.21DCL23-C✓✓1
PWR070Declare array dummy arguments as assumed-shape arrayscorrectness, modernization, securityCWE-1306.8, 6.9, 6.10API02-C✓
PWR071Prefer real(kind=kind_value) for declaring consistent floating typesmodernization, portability, securityCWE-1102, CWE-13396.2, 6.4, 6.6FLP00-C✓
PWR072Explicitly declare the 'save' attribute or split the variable initialization to prevent unintended behaviorcorrectness, securityCWE-6656.54✓✓1
PWR073Transform common block into a module for better data encapsulationcorrectness, modernization, securityCWE-1083, CWE-11086.37, 6.53DCL19-C✓
PWR074Pass only required fields from derived type as arguments to increase code claritymodernization✓✓✓
PWR075Avoid using compiler-specific Fortran extensionsmodernization, portability, securityCWE-474, CWE-11036.57MSC23-C✓
PWR079Avoid undefined behavior due to uninitialized variablescorrectness, portability, securityCWE-758, CWE-908, CWE-9096.13, 6.22, 6.56EXP33-C, EXP34-C, MSC15-CEXP53-CPP✓✓✓
PWR080Conditionally initialized variables can lead to undefined behaviorcorrectness, portability, securityCWE-758, CWE-908, CWE-9096.13, 6.22, 6.56EXP33-C, EXP34-C, MSC15-CEXP53-CPP✓✓✓
PWR081Uninitialized output arguments can lead to undefined behaviorcorrectness, portability, securityCWE-758, CWE-908, CWE-9096.13, 6.22, 6.56EXP33-C, EXP34-C, MSC15-C✓
PWR082Remove unused variablescorrectness, securityCWE-5636.19MSC13-C✓✓✓
PWR083Match the types of dummy and actual arguments in procedure callscorrectness, securityCWE-628, CWE-7586.11, 6.32, 6.53, 6.56EXP37-C, MSC15-C✓
PWR085Favor iterative implementations over recursion to prevent stack overflowssecurityCWE-6746.35, 6.43✓✓✓
PWR086Prefer array-based notation over pointer-based notation for readabilitysecurityCWE-468EXP08-C✓✓
PWR087Declare array dummy arguments as assumed-shape arrays to favor compiler optimizationsoptimization✓
PWR088Add missing arguments to procedure callscorrectness, securityCWE-628, CWE-7586.32, 6.56EXP37-C, MSC15-C✓
PWR089Remove unexpected arguments from procedure callscorrectness, securityCWE-628, CWE-7586.32, 6.56EXP37-C, MSC15-C✓
PWD002Unprotected multithreading reduction operationcorrectness, securityCWE-366, CWE-8206.61CON07-C, CON43-C✓✓✓
PWD003Missing array range in data copy to the GPUcorrectness, securityCWE-131, CWE-7586.56MSC15-C✓✓✓
PWD004Out-of-memory-bounds array accesscorrectness, securityCWE-125, CWE-7876.8, 6.9, 6.10ARR30-C✓✓✓
PWD005Array range copied to or from the GPU does not cover the used rangecorrectness, securityCWE-125, CWE-131, CWE-7876.8, 6.9, 6.10ARR30-C✓✓✓
PWD006Missing deep copy of non-contiguous data to the GPUcorrectness, securityCWE-125, CWE-758, CWE-787, CWE-9086.56ARR30-C, EXP33-C, MSC15-C✓✓✓
PWD007Unprotected multithreading recurrencecorrectness, securityCWE-366, CWE-8206.61CON43-C✓✓✓
PWD008Unprotected multithreading recurrence due to out-of-dimension-bounds array accesscorrectness, securityCWE-125, CWE-366, CWE-787, CWE-8206.8, 6.9, 6.10, 6.56, 6.61ARR30-C, CON43-C, MSC15-C✓✓✓
PWD009Incorrect privatization in parallel regioncorrectness, securityCWE-821✓✓✓
PWD010Incorrect sharing in parallel regioncorrectness, securityCWE-366, CWE-8216.61CON43-C✓✓✓
PWD011Missing OpenMP lastprivate clausecorrectness, securityCWE-821✓✓✓
RMK010Strided memory accesses in the loop body may prevent vectorizationoptimization✓✓✓
RMK012Conditional execution in the loop body may prevent vectorizationoptimization✓✓✓
RMK013Low trip count unknown at compile time may prevent vectorization of the loopoptimization✓✓✓
RMK014Unpredictable memory accesses in the loop body may prevent vectorizationoptimization✓✓✓
RMK015Tune compiler optimization flags to increase the speed of the codeoptimization✓✓✓
RMK016Tune compiler optimization flags to avoid potential changes in floating point precisioncorrectness, securityCWE-189FLP01-C✓✓✓

CWE, ISO/IEC 24772-8, SEI CERT C, and SEI CERT C++: Map checks in the Open Catalog to major security standards to clarify their relevance to software security.

AutoFix: Denotes tools that support automatic correction of the corresponding check. Readers are encouraged to report additional tools with autofix capabilities for these checks. The tools are tagged in the table as detailed in the footnotes.

Contributing​

We welcome and encourage contributions to the Open Catalog! Here's how you can get involved:

  1. Join the discussion:

    Got ideas, questions, or suggestions? Head over to our GitHub Discussions. It's the perfect place for open-ended conversations and brainstorming!

  2. Report issues:

    Found inaccuracies, unclear explanations, or other problems? Please open an Issue. Detailed reports help us quickly improve the quality of the project!

  3. Submit pull requests:

    Interested in solving any issues? Feel free to fork the repository, make your changes, and submit a Pull Request. We'd love to see your contributions!

Footnotes​

  1. Codee ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13