rrthomas / mit

A simple stack-based VM
Other
10 stars 3 forks source link

Uninitialised variable warning in specializer #287

Closed rrthomas closed 5 years ago

rrthomas commented 5 years ago

Clang reports this for the code generated by:

while cache_state.cached_depth > 0:
    switch_code.append('case {}:'.format(cache_state.cached_depth))
    case_code = Code()
    case_code.extend(cache_state.flush(cache_state.cached_depth - 1))
    case_code.append('// Falls through.')
    switch_code.append(case_code)

The state_n variables (specifically here, state_4 with current head of branch appveyor-fixes) can be uninitialised when flushed. Not a problem (?) but I guess we should turn off the warning explicitly?

apt1002 commented 5 years ago

Interesting that GCC does not warn. On every path that reaches this switch the selector is a compile-time constant. Apparently GCC understands that and Clang does not.

I'm happy with suppressing this warning, but it might be better to initialise the variables to a dummy value.