Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Two internal headers are still using NULL #108741

Closed
frederick-vs-ja opened this issue Sep 15, 2024 · 0 comments · Fixed by #108847
Closed

[libc++] Two internal headers are still using NULL #108741

frederick-vs-ja opened this issue Sep 15, 2024 · 0 comments · Fixed by #108847
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Sep 15, 2024

inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; }
inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; }
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }

inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
const size_t buff_size = 256;
if ((*strp = (char*)malloc(buff_size)) == NULL) {
return -1;
}
va_list ap_copy;
// va_copy may not be provided by the C library in C++03 mode.
#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
__builtin_va_copy(ap_copy, ap);
#else
va_copy(ap_copy, ap);
#endif
int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
va_end(ap_copy);
if ((size_t)str_size >= buff_size) {
if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {
return -1;
}
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
}
return str_size;
}

Given libc++'s <__config> supports nullptr in ancient C++03 mode

# define nullptr __nullptr

Should we just replace these uses of NULL with nullptr?

@github-actions github-actions bot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 15, 2024
ldionne added a commit to ldionne/llvm-project that referenced this issue Sep 16, 2024
tmsri pushed a commit to tmsri/llvm-project that referenced this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant