File: example.c
int divide(int a, int b) return a / b; // Potential division by zero
void copy_buffer(int* dest, int* src, int size) for (int i = 0; i <= size; i++) // Off-by-one: should be i < size dest[i] = src[i];
Command (Code Prover):
polyspace-code-prover -sources example.c -main-generator -entry-points divide,copy_buffer -target-compiler gcc10 -runtime-range-analysis
Expected Output:
Fix & Re-run:
int divide(int a, int b) if (b == 0) return 0; // Green after fix return a / b;
void copy_buffer(int* dest, int* src, int size) for (int i = 0; i < size; i++) // Green dest[i] = src[i];polyspace r2021a
Even though newer releases (R2022a, R2023b, R2024a) exist, R2021a remains a favorite for teams locked into specific legacy compiler toolchains. Specifically: File: example
However, if you require C++20 support or AUTOSAR C++14 guidelines, you should skip R2021a and move to R2023b or newer.