8000 Fix unintialized pointer warning in Objects/obmalloc.c by hansrajdas · Pull Request #15293 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Fix unintialized pointer warning in Objects/obmalloc.c #15293

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

Closed
wants to merge 1 commit into from

Conversation

hansrajdas
Copy link
Contributor

Steps to reproduce, check compilation logs:

make clean;make

warning-2019-08-15 01-15-06

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is useless and would have a big negative impact on performances.

If you want initialized memory, use PyObject_Calloc(), not PyObject_Malloc(). PyObject_Malloc() returns uninitialized memory by design.

I understand that the compiler warnings says that ptr value may be initialized. GCC is wrong: it is always initialized. What is your GCC version? What is your OS? Please open a bug report.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vstinner vstinner closed this Aug 14, 2019
@vstinner
Copy link
Member

If you want the compiler bug to be fixed, please open a bug report. But this change is wrong, so I closed the PR.

@hansrajdas
Copy link
Contributor Author

Thanks @vstinner for your valuable inputs. I am using Ubuntu 18.04.2 LTS and GCC version 7.4.0-1ubuntu1~18.04.1. I will open a bug for this compiler warning.

As PyObject_Malloc is designed to return uninitialized memory, we can assign ptr to NULL(void* ptr = NULL) while declaration to fix this warning, will this be a better approach?

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

Successfully merging this pull request may close these issues.

4 participants
0