Skip to content

Conversation

fxing-qnx
Copy link

@fxing-qnx fxing-qnx commented Jan 16, 2025

As the title says. Almost same as #988, but fix undefined behavior in xmltest.
#988 can be closed since this fix is a generalization of it.

@fxing-qnx fxing-qnx changed the title Add support for QNX Add support for QNX & Fix xmltest UB Jan 16, 2025
@leethomason
Copy link
Owner

That seems to make sense on the surface, but why are nulls coming back? Most things will crash on null pointers being printed.

@fxing-qnx
Copy link
Author

fxing-qnx commented Jun 9, 2025

#include <stdio.h>

int main(int argc, char** argv)
{
	printf("%s", NULL);
	return 0;
}

This simple test program will output (null) on Debian 13 with GCC 14.2.0.

7.1.4 Use of library functions.
Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined.

printf(...) on null pointer is undefined, hence there is no specification saying it should result in any kinds of failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants