Unreachable code in functions with out value
@carlosg
Submitted by Carlos Garnacho Link to original bug (#778303)
Description
Created attachment 345137 reproducer
If a function has an out value, but it bothers to return early in all its code branches instead of waiting to the end of the function, vala inserts code anyway trying to assign the internal value to the out pointer, for the example attachment:
void foo_bar (Foo* self, gint i, MyEnum* outval, GError** error) {
...
switch (_tmp0_) {
case 0:
{
_vala_outval = MY_ENUM_A;
if (outval) {
*outval = _vala_outval;
}
return;
}
default:
{
_vala_outval = MY_ENUM_B;
if (outval) {
*outval = _vala_outval;
}
return;
}
}
if (outval) {
*outval = _vala_outval;
}
}
This triggers one Coverity warning about "Structurally dead code" in Tracker, CID 1388510.
Attachment 345137, "reproducer":
test2.vala