kphp icon indicating copy to clipboard operation
kphp copied to clipboard

Switch with 0 case produces a g++ warning

Open quasilyte opened this issue 3 years ago • 1 comments

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;
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

quasilyte avatar Dec 27 '22 10:12 quasilyte

Probably, it has been fixed with https://github.com/VKCOM/kphp/pull/727

tolk-vm avatar Feb 14 '23 10:02 tolk-vm