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

Fix string ctor param from strstr #38

Merged
merged 1 commit into from
Jun 4, 2021

Conversation

gjimye
Copy link
Contributor

@gjimye gjimye commented May 14, 2021

When using the (begin, end) constructor for string, the types of begin
and end must match, including cv qualifiers. Depending on the library
headers used, strstr(const char *, const char *) can potentially return
char * or const char *, the former being a call to the C function strstr
and the latter being a call to C++ std::strstr.

This commit fixes the clang portion of issue #21, by explicitly casting
the return value of strstr to match the 1st param of the string ctor so
that the ctor can be instantiated regardless of the header used.

@gjimye gjimye marked this pull request as ready for review May 14, 2021 15:39
@rui314 rui314 force-pushed the main branch 5 times, most recently from 4d1a1bd to a0a94f4 Compare May 21, 2021 16:54
@rui314 rui314 force-pushed the main branch 4 times, most recently from ae0019b to 3fab4ce Compare May 23, 2021 07:21
@rui314
Copy link
Owner

rui314 commented Jun 4, 2021

Thank you for your patch! Could you read https://github.com/rui314/mold/blob/main/CONTRIBUTING.md and add a Signed-off-by line to your commit message?

When using the (begin, end) constructor for string, the types of begin
and end must match, including cv qualifiers. Depending on the library
headers used, strstr(const char *, const char *) can potentially return
char * or const char *, the former being a call to the C function strstr
and the latter being a call to C++ std::strstr.

This commit fixes the clang portion of issue rui314#21, by explicitly casting
the return value of strstr to match the 1st param of the string ctor so
that the ctor can be instantiated regardless of the header used.

Signed-off-by: Jim Ye <gjimye@gmail.com>
@gjimye gjimye force-pushed the fix/string-constructor-type-error branch from 00dafd1 to 9c304f7 Compare June 4, 2021 16:02
@gjimye
Copy link
Contributor Author

gjimye commented Jun 4, 2021

Thank you for your patch! Could you read https://github.com/rui314/mold/blob/main/CONTRIBUTING.md and add a Signed-off-by line to your commit message?

Done, thanks!

@rui314 rui314 merged commit 7f7507a into rui314:main Jun 4, 2021
@rui314
Copy link
Owner

rui314 commented Jun 4, 2021

Thanks! I merged your commit. You are the first contributor to this project!

@gjimye gjimye deleted the fix/string-constructor-type-error branch June 5, 2021 11:43
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.

None yet

2 participants