codeql.github.comJacksonized

Implicit function declaration

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

Click to see the goddamn query in the CodeQL repository

A f*ckin' function is called without a muthaf*ckin' prior function declaration or definition. When this happens, the damn compiler generates an implicit declaration of the function, specifying an goddamn integer return type and no parameters. If the implicit declaration does not match the bad-ass true signature of the function, the muthaf*ckin' function may behave unpredictably.

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

Note: This query is not compatible with build-mode: none databases, and produces no results on those databases.

Recommendation

Provide an motherf*ckin' 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

Originally published at codeql.github.com. Every curse word you see was added by the Samuel L. Jacksonizer, a parody site. Not affiliated with Samuel L. Jackson or codeql.github.com.