Missing warning for unused code

ASSI Stromeko at nexgo.de
Wed Aug 19 18:10:54 UTC 2026


Hal Murray via devel writes:
> I fatfingered something and ended up with this code:
>                     default:
>                         snprintf(errbuf, errlng,
>                                 "Received strange type: T=%d, C=%d, L=%d",
>                                 type, critical, length);
>                         return false;
>                         buf->next += length;
>                         buf->left -= length;
>                         break;
>
> The compiler didn't complain.  I expect a warning.
>
> I just poked in the man page.  There is -Wunused which turns on a bunch of 
> -Wunused-xxx, but none of the xxxs are code.  Am I missing something?

The warning that would apply here is "unreachable code".  However,
(assuming you talk about gcc) that warning was removed around gcc-4 as
it relied on the optimizer and therefore produced unstable results (I
think there was an attempt to implement something more restricted via
GIMPLE instead, but it doesn't ssem to have landed).  It's also one of
the things that are theoretically impossible to do correctly in general
as you'd need to solve the halting problem.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra



More information about the devel mailing list