Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22048

How to hint to GCC that a line should be unreachable at compile time?

$
0
0

It's common for compilers to provide a switch to warn when code is unreachable. I've also seen macros for some libraries, that provide assertions for unreachable code.

Is there a hint, such as through a pragma, or builtin that I can pass to GCC (or any other compilers for that matter), that will warn or error during compilation if it's determined that a line expected to be unreachable can actually be reached?

Here's an example:

    if (!conf->devpath) {        conf->devpath = arg;        return 0;    } // pass other opts into fuse    else {        return 1;    }    UNREACHABLE_LINE();

The value of this is in detecting, after changes in conditions above the expected unreachable line, that the line is in fact reachable.


Viewing all articles
Browse latest Browse all 22048

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>