CodeQL documentation

Implicit function declaration

ID: cpp/implicit-function-declaration
Kind: problem
Security severity: 
Severity: warning
Precision: high
Tags:
   - correctness
   - maintainability
Query suites:
   - cpp-security-and-quality.qls

Click to see the query in the CodeQL repository

A function is called without a prior function declaration or definition. When this happens, the compiler generates an implicit declaration of the function, specifying an integer return type and no parameters. If the implicit declaration does not match the true signature of the function, the function may behave unpredictably.

This may indicate a misspelled function name, or that the required header containing the function declaration has not been included.

Recommendation

Provide an explicit declaration of the function before invoking it.

Example

/* '#include <stdlib.h>' was forgotten */

int main(void) {
	/* 'int malloc()' assumed */
	unsigned char *p = malloc(100);
	*p = 'a';
	return 0;
}

References

  • © GitHub, Inc.
  • Terms
  • Privacy
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy