C and C++


BADMACRO.STDARG_H : Use of <stdarg.h> Feature

Summary

A use of one of the following macros from <stdarg.h>: va_arg(), va_start(), va_end(), va_copy().

Properties

Class Name Use of <stdarg.h> Feature
Significance reliability
Mnemonic BADMACRO.STDARG_H
Categories
MisraC2023 MisraC2023:17.1 The standard header file <stdarg.h> shall not be used
Misra2012 Misra2012:17.1 The standard header file <stdarg.h> shall not be used
AUTOSARC++14 AUTOSARC++14:A1-1-1 All code shall conform to ISO/IEC 14882:2014 - Programming Language C++ and shall not use deprecated features.
MisraC++2023 MisraC++2023:4.1.2 Deprecated features should not be used
  MisraC++2023:21.10.1 The features of <cstdarg> shall not be used
CERT-C CERT-C:EXP47-C Do not call va_arg with an argument of the incorrect type
  CERT-C:MSC38-C Do not treat a predefined identifier as an object if it might only be implemented as a macro
  CERT-C:MSC39-C Do not call va_arg() on a va_list that has an indeterminate value
CERT-CPP CERT-CPP:EXP58-CPP Pass an object of the correct type to va_start
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Use of <stdarg.h> Feature"

Example

#include <stdarg.h>

int var_add ( int numargs, ... ){    
    int retval=0;
    int i;
    va_list args;                        /* 'Use of <stdarg.h> Feature' warning issued here */
    
    va_start(args, numargs);             /* 'Use of <stdarg.h> Feature' warning issued here */
    for (i = 0; i < numargs; i++){
        retval += va_arg(args, int);     /* 'Use of <stdarg.h> Feature' warning issued here */
    }
    va_end(args);                        /* 'Use of <stdarg.h> Feature' warning issued here */
    return retval;
}

Relevant Configuration File Parameters

This class is implemented using a BAD_MACRO_* rule set in the general template configuration file.

The following configuration file parameters affect checks for this warning class.