Skip to content

gh-106797: Remove warning logs from Python/generated_cases.c.h #106798

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

Merged
merged 5 commits into from
Jul 17, 2023

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Jul 16, 2023

@corona10
Copy link
Member Author

In file included from Python/ceval.c:770:
Python/generated_cases.c.h:3437:48: warning: code will never be executed [-Wunreachable-code]
            if (0) { stack_pointer[-(1 + 0)] = res2; }
                                               ^~~~
Python/generated_cases.c.h:3437:17: note: silence by adding parentheses to mark code as explicitly dead
            if (0) { stack_pointer[-(1 + 0)] = res2; }
                ^
                /* DISABLES CODE */ ( )
Python/generated_cases.c.h:3415:48: warning: code will never be executed [-Wunreachable-code]
            if (0) { stack_pointer[-(1 + 0)] = res2; }
                                               ^~~~
Python/generated_cases.c.h:3415:17: note: silence by adding parentheses to mark code as explicitly dead
            if (0) { stack_pointer[-(1 + 0)] = res2; }
                ^
                /* DISABLES CODE */ ( )
clang -c -fno-strict-overflow -Wsign-compa

Warning logs are reduced, but not sure this is a safe way.

@gvanrossum
Copy link
Member

The if (0) and if (1) can easily be simplified too. It's these lines in assign():

            stmt = f"{dst.name} = {cast}{src.name};"
            if src.cond:
                stmt = f"if ({src.cond}) {{ {stmt} }}"
            self.emit(stmt)

@corona10 corona10 changed the title gh-106797: Reduce warning logs from Python/generated_cases.c.h gh-106797: Remove warning logs from Python/generated_cases.c.h Jul 16, 2023
@corona10
Copy link
Member Author

corona10 commented Jul 16, 2023

@gvanrossum

It works and it will introduce another warning :)
This issue should be solved separately

Python/generated_cases.c.h:3394:23: warning: unused variable 'res2' [-Wunused-variable]
            PyObject *res2 = NULL;

@corona10 corona10 requested a review from gvanrossum July 16, 2023 04:58
@corona10
Copy link
Member Author

corona10 commented Jul 16, 2023

It looks like it needs a keyword for res2 if (0) case, which unused keyword can not replace.

@corona10 corona10 changed the title gh-106797: Remove warning logs from Python/generated_cases.c.h gh-106797: Reduce warning logs from Python/generated_cases.c.h Jul 16, 2023
@corona10 corona10 changed the title gh-106797: Reduce warning logs from Python/generated_cases.c.h gh-106797: Remove warning logs from Python/generated_cases.c.h Jul 16, 2023
@corona10
Copy link
Member Author

corona10 commented Jul 16, 2023

It looks like it needs a keyword for res2 if (0) case, which unused keyword can not replace.

I solved the issue by using the same approach which was used for assigning rule :)

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks -- that should do it, merge it!

@corona10 corona10 merged commit 48956cc into python:main Jul 17, 2023
@corona10 corona10 deleted the gh-106797 branch July 17, 2023 00:09
gvanrossum added a commit that referenced this pull request Jul 18, 2023
These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706).
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.

3 participants