Skip to content

Fix GCC warning when using getThis() in a conditional #13923

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 1 commit into from
Apr 9, 2024

Conversation

arnaud-lb
Copy link
Member

@arnaud-lb arnaud-lb commented Apr 9, 2024

Since GCC 12.x, using getThis() in a conditional yields a warning:

<source>:12:22: warning: the comparison will always evaluate as 'true' for
                the address of 'This' will never be NULL [-Waddress]
   12 |     return getThis() ? 2 : 3;
      |                      ^

See example here.

GCC considers this is not a bug, and that only the diagnostic location is wrong.

Since GCC 12.x, using getThis() in a conditional yields a warning:

    <source>:12:22: warning: the comparison will always evaluate as 'true' for
                    the address of 'This' will never be NULL [-Waddress]
       12 |     return getThis() ? 2 : 3;
          |                      ^
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

I have not searched the code base for other cases, but the ones listed here make sense!

@arnaud-lb arnaud-lb marked this pull request as ready for review April 9, 2024 17:08
@arnaud-lb arnaud-lb merged commit fd73681 into php:master Apr 9, 2024
10 checks passed
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.

2 participants