This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_custom_op_get_field(): remove undef behaviour
authorDavid Mitchell <davem@iabyn.com>
Fri, 30 Oct 2020 20:50:58 +0000 (20:50 +0000)
committerDavid Mitchell <davem@iabyn.com>
Fri, 30 Oct 2020 20:50:58 +0000 (20:50 +0000)
commite050064b67c501e9fdc7bc3f513ba2b8b9e795f8
treee22e1acf43eaf92b1a72b0d734f5373ea6cd81a9
parentc8c367581c3333c38d07481e2ea8d81171403c81
Perl_custom_op_get_field(): remove undef behaviour

Thus function has a couple a switches with

               default:
                   NOT_REACHED; /* NOTREACHED */

but clang is complaining that the value returned by the function is
undefined if those default branches are taken, since the 'any' variable
doesn't get set in that path.

Replace the NOTREACHED with a croak("panic: ..."). It's possible (albeit
not intended) for Perl_custom_op_get_field() to be called with a 'field'
arg which triggers the default case. So if this ever happens, make it
clear that something has gone wrong, rather than just silently
continuing on non-debugging builds.

In any case, this shuts up clang.
op.c