kphp
kphp copied to clipboard
Switch with 0 case produces a g++ warning
Reproducer:
<?php
function test() {
switch (1) {}
}
test();
Expected result: KPHP compiler warning/error or no output. Actual result: we get a confusing C++ compiler warning for something that is not understandable for KPHP user.
test.cpp:9:8: warning: variable ‘v$matched_with_one_case$ud1d16a4a0a7a19fb_0’ set but not used [-Wunused-but-set-variable]
9 | bool v$matched_with_one_case$ud1d16a4a0a7a19fb_0 = false;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Probably, it has been fixed with https://github.com/VKCOM/kphp/pull/727