Main Content

Fix Polyspace Compilation Errors About Large Objects

Issue

The analysis stops during compilation with a message indicating that an object is too large.

Cause

The error happens when the software detects an object such as an array, union, structure, or class, that is too big for the pointer size of the selected target.

For instance, you get the message, Limitation: struct or union is too large in the following example. You specify a pointer size of 16 bits. The maximum object size allocated to a pointer, and therefore the maximum allowed size for an object, can be 216-1 bytes. However, you declare a structure as follows:

  • struct S 
    { 
      char tab[65536]; 
    }s; 
    
  • struct S 
    { 
      char tab[65534]; 
      int val;
    }s; 
    

Solution

  1. Check the pointer size that you specified through your target processor type. For more information, see Target processor type (-target).

    For instance, in the following, the pointer size for a custom target My_target is 16 bits.

  2. Change your code or specify a different pointer size.

    For instance, you can:

    • Declare an array of smaller size in the structure.

      If you are using a predefined target processor type, the pointer size is likely to be the same as the pointer size on your target architecture. Therefore, your declaration might cause errors on your target architecture.

    • Change the pointer size of the target processor type that you specified, if possible.

      Otherwise, specify another target processor type with larger pointer size or define your own target processor type. For more information on defining your own processor type, see Generic target options.

      Note

      Polyspace® imposes an internal limit of 128 MB on the size of data structures. Even if your target processor type specification allows data structures of larger size, this internal limit constrains the data structure sizes.