Thanks for the reply. I had thought this would work as well, but consider the following code: void elsewhere(void* ptr); int main() { elsewhere( && LABEL ); return 0; LABEL: __asm__(";look at me"); } Compiling this with `gcc -O0 -S -Wunreachable-code unreach.c` produces a warning calling the label unreachable. In fact, visual inspection of the produced assembly confirms that the comment "look at me" is not generated. This is on the gcc 4.1.2 distributed by Gentoo, with equivalent remarks on Debian's gcc, whose version I don't know at the moment. The only means I've found of `tricking` gcc into thinking code is reachable is to place a goto to it inside a conditional whose condition depends upon a global or volatile variable ( that is always false in reality ). However, the code I'm generating would have one of these unreachable blocks in every function, so that's a lot of volatile variables and/or globals to mess up the optimizer and/or cache locality. What would be ideal (and it might not be possible, but that's what I'm asking) is if there's some way to either a) generate code despite its being unreachable, or b) a means of tricking gcc into believing code is reachable that incurs no runtime cost. Thanks! On Wed, Jul 1, 2009 at 12:04 AM, Jeff Law<law@xxxxxxxxxx> wrote: > Patrick Moran wrote: >> >> Hello all, >> I was wondering if there is some means of directing gcc to generate >> unreachable code? Either a means to do so globally or a specific >> scope would be great. I wish to generate some code which employs >> inline assembly and/or libunwind to do a type of exception handling >> not possible in standard C. >> >> Don't get me wrong - the compiler is correct. The generated code is >> unreachable via any standard C control flow mechanism, but I'd really >> like it to generate the code anyways. Is there any way to do this? >> > > Put a label before the block of code, then take the address of the label and > pass it to a function defined in another compilation unit? That should > make the compiler think the code in question is reachable and thus prevent > it from being deleted. > > jeff > >