Global register variable definition is removed as dead code

Ian Lance Taylor
Wed Dec 7 06:22:00 GMT 2011

Pitchumani Sivanupandi <> writes:

> Consider the following test case:
> // gcc-4.6.1// option: -O1
> register void  *ptr asm("rbx") ;
> void testfn1(void* func){  ptr = func;  // removed as dead code  goto *ptr;}
> When compiling with O1 option, 'ptr = func' definition is removed as dead code. But ref[1] says it should not be deleted even if it appears to be dead.
> In dead code elimination (gcc/dce.c), the register definition is not checked for "global register variable".
> Is gcc's behaviour is correct?
> ref1:

That is definitely a bug.  Please file a bug report as described at .  Thanks.


More information about the Gcc-help mailing list