You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
#[\NoDiscard] with PHP function version of call_user_func() does not produce any warning. #25028
Warning: The return value of function test() should either be used or intentionally ignored by casting it as (void) in %s on line %d
The root cause is that there is no handling of a potential #[\NoDiscard] attribute in the PHP_FUNCTION(call_user_func) version. I'm guessing this also not handled in PHP_FUNCTION(call_user_func_array), PHP_FUNCTION(forward_static_call), and PHP_FUNCTION(forward_static_call_array).
This is working as designed: Internally call_user_func()is consuming the return value of test() - it's just that the return value of call_user_func() is unused and we cannot make the attribute conditional.
6. but note that due to the optimizer, the behaviour changes:
Yes, I'm aware. I would consider that to be one of the acceptable behavioral differences introduced by optimization. Technically the optimizer could emit a (void) cast there, but that is probably not worth it, particularly since call_user_func() is likely rarely used in modern code (due to more ergonomic alternatives).
Activity
TimWolla commentedon Oct 29, 2026
This is working as designed: Internally
call_user_func()is consuming the return value oftest()- it's just that the return value ofcall_user_func()is unused and we cannot make the attribute conditional.ndossche commentedon Oct 29, 2026
I agree with your reasoning, but note that due to the optimizer, the behaviour changes: https://3v4l.org/oJ3IK#v
TimWolla commentedon Oct 29, 2026
Yes, I'm aware. I would consider that to be one of the acceptable behavioral differences introduced by optimization. Technically the optimizer could emit a
(void)cast there, but that is probably not worth it, particularly sincecall_user_func()is likely rarely used in modern code (due to more ergonomic alternatives).Girgias commentedon Oct 29, 2026
Sure, I don't have strong feelings about it. Will close as won't fix.