Fix Polyspace Compilation Errors Related to GNU Compiler
If you choose gnu for the option Compilation toolchain (Static analysis), you can encounter
this issue.
Issue
The Polyspace® analysis stops with a compilation error.
Cause
You are using certain advanced compiler-specific extensions that Polyspace does not support.
Solution
For easier portability of your code, avoid using the extensions.
If you want to use the extensions and still analyze your code, wrap the unsupported extensions in a preprocessor directive. For instance:
#ifdef POLYSPACE
// Supported syntax
#else
// Unsupported syntax
#endifPOLYSPACE for regular compilation but for Polyspace analysis, enter POLYSPACE for the option Preprocessor definitions (-D).If the compilation error is related to assembly language code, use the option -asm-begin -asm-end.
Note that Polyspace does not support the following features of GNU compilers.
GNU® compilers versions 4.7 and later:
Nested functions.
For instance, the function
baris nested in functionfoo:int foo (int a, int b) { int bar (int c) { return c * c; } return bar (a) + bar (b); }Binary operations with vector types where one operand uses the shorthand notation for uniform vectors.
For instance, in the addition operation,
2+a, 2 is used as a shorthand notation for {2,2,2,2}.typedef int v4si __attribute__ ((vector_size (16))); v4si res, a = {1,2,3,4}; res = 2 + a; /* means {2,2,2,2} + a */Forward declaration of function parameters.
For instance, the parameter
lenis forward declared:void func (int len; char data[len][len], int len) { /* … */ }Complex integer data types.
However, complex floating point data types are supported.
Initialization of structures with flexible array members using an initialization list.
For instance, the structure
Shas a flexible array membertab. A variable of typeSis directly initialized with an initialization list.You see a warning during analysis and a red check in the results when you dereference, for instance,struct S { int x; int tab[]; /* flexible array member - not supported */ }; struct S s = { 0, 1, 2} ;s.tab[1].128-bit variables.
Polyspace cannot analyze this data type semantically. Bug Finder allows use of 128-bit data types, but Code Prover shows a compilation error if you use such a data type, for instance, the GCC extension
__float128.
GNU compilers version 7.x:
Type names
_FloatNand_FloatNxare not semantically supported. The analysis treats them as typefloat,double, orlong double.Constants of type
_FloatNor_FloatNxwith suffixesfN,FN, orfNx, such as1.2f123or2.3F64xare not supported.