[php-src] PR #13923: Fix GCC warning when using getThis() in a conditional

From: Date: Tue, 09 Apr 2024 13:44:34 +0000
Subject: [php-src] PR #13923: Fix GCC warning when using getThis() in a conditional
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-25685@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/13923 Author: arnaud-lb 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](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,selection:(endColumn:16,endLineNumber:9,positionColumn:16,positionLineNumber:9,selectionStartColumn:16,selectionStartLineNumber:9,startColumn:16,startLineNumber:9),source:'++++struct+%7B%0A++++struct+%7B%0A%09++++_Bool+is_object%3B%0A++++%7D+This%3B%0A%7D+ex%3B%0A%0Aint+effect%3B%0A%0A%23define+getThis()+((%26ex.This)-%3Eis_object+%3F+%26ex.This+:+0)%0A%0Aint+f(void)+%7B%0A++++return+getThis()+%3F+2+:+3%3B%0A%7D%0A'),l:'5',n:'0',o:'C+source+%232',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:cg121,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,libs:!(),options:'-Wall',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:2),l:'5',n:'0',o:'+x86-64+gcc+12.1+(Editor+%232)',t:'0')),k:33.33333333333333,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+gcc+13.2',editorid:2,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gcc+12..1+(Compiler+%231)',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4). getThis() ? 2 : 3 is expanded to something like ``` (execute_data->This.type == IS_OBJECT ? &execute_data->This : NULL) ? 2 : 3 ``` GCC considers this is not a bug, and that only the diagnostic location is wrong.

« previous php.git-pulls (#25685) next »