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

Replace useless tid parameters with NULL #1623

Closed
wants to merge 1 commit into from

Conversation

zorjen122
Copy link

No description provided.

@Barenboim
Copy link
Contributor

At least, on macOS with clang, the function requires a non-null argument:

test.c:11:36: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
        pthread_create(NULL, NULL, f, NULL);

@Barenboim
Copy link
Contributor

zsh: segmentation fault  ./a.out

@Barenboim
Copy link
Contributor

But this is legal :)

{
    pthread_create(&(pthread_t){0}, NULL, f, NULL);
}

@zorjen122
Copy link
Author

至少,在带有 clang 的 macOS 上,该函数需要一个非 null 参数:

test.c:11:36: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
        pthread_create(NULL, NULL, f, NULL);

After consulting posix data, yes, usually the compiler pthread_create implementation will dereference "tid" when attr==NULL. Thanks for your reply.
[posix-pthread_create]“....Upon successful completion, pthread_create() shall store the ID of the created thread in the location referenced by thread.”

@zorjen122 zorjen122 closed this Sep 17, 2024
@zorjen122 zorjen122 deleted the zorjen122-workflow branch September 17, 2024 03:49
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.

2 participants