MISRA C:2023 Rule 21.24
Description
Rule Definition
        The random number generator functions of <stdlib.h>
               shall not be used.1
      
      
Rationale
The numbers generated by rand() are pseudorandom and depend on a
            seed set by srand(). Because of this, the numbers generated by
               rand() can be predicted and are cryptographically weak. Using
               srand() by itself is superfluous as the code sets a seed value for
            random number generation but does not use it.
Polyspace Implementation
        Polyspace® reports a violation of this rule whenever the code contains
               rand() or srand().
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group:Standard Libraries | 
| Category: Required | 
| AGC Category: Required | 
Version History
Introduced in R2024a
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.