-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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::execv incorrect definition #16290
Comments
#include <stdio.h>
#define typename(x) _Generic((x), \
char *const *: "char *const *", \
default: "unreachable!()")
void f(char *const x[]) {
puts(typename(x));
}
int main(void) {
f(0);
} (only works in clang) |
But the definition is still wrong. pub unsafe fn execv(prog: *const c_char, argv: *const *mut c_char) -> c_int |
Interestingly enough, the example in POSIX 2008 disregards the inner mutability in its execv example: #include <unistd.h>
int main(void) {
char *const cmd[] = { "ls", "-l", (char *)0 };
execv("/bin/ls", cmd);
}
I'm not quite sure what to believe. |
A thorough reading of POSIX 2008 reveals that execv will never modify any level of the argv parameter. See the following screenshot for a detailed explanation (compatibility with old code). |
Today, this is
so it appears that it's still wrong. |
PR #25641 should fix this. I didn't notice this issue at the time, but I reached the same conclusions about the actual const guarantees (and C's legacy problems therewith). |
internal: Reduce vec cloning in mir lowering/eval
It should be:
The text was updated successfully, but these errors were encountered: