title: Address of a variable does not matches in gdb
body: <p>I am using Intel's ICC compiler for NetBSD systems.
  I have been fighting with a bug, and got surprised even more when I observed that from the core dump - address of a symbol  from two different mechanisms in gdb are not same.</p>
  
  <p>The variable <em>connection_out</em> seems to have different address when checked with "<em>info symbol connection_out</em>" and <em>p &amp;connection_out</em>.</p>
  
  <p>Does it looks like a compiler problem where <em>badf_errcnt</em> which was optimized into CPU registers, is assigned a memory location, and thereafter compiler got confused between two ?</p>
  
  <p><strong>EDIT1</strong>: the variable <em>connection_out</em> is a <em>static int</em> global variable</p>
  
  <pre><code>gdb$ disassemble sigusr1_rt
  Dump of assembler code for function sigusr1_rt:
     0x01845000 &lt;+0&gt;:     push   %ebp
     0x01845001 &lt;+1&gt;:     mov    %esp,%ebp
     0x01845003 &lt;+3&gt;:     sub    $0x8,%esp
     0x01845006 &lt;+6&gt;:     movl   $0x16c156a,0x188f05c
     0x01845010 &lt;+16&gt;:    mov    %ebp,%esp
     0x01845012 &lt;+18&gt;:    pop    %ebp
     0x01845013 &lt;+19&gt;:    ret    
     0x01845014 &lt;+20&gt;:    lea    0x0(%esi),%esi
     0x0184501a &lt;+26&gt;:    lea    0x0(%edi),%edi
  End of assembler dump.
  gdb$ info symbol 0x188f05c
  connection_out in section .bss of /sites/eqx/work/swcores/tripunjay/F10ACOREDIR/f10cp_sshd.login-eqx-06.6402/sshd
  gdb$ p &amp;connection_out
  $10 = (int *) 0x188f048
  gdb$ p/d 0x188f05c - 0x188f048
  $11 = 20
  gdb$ p/x 0x188f05c - 0x188f048 
  $12 = 0x14
  gdb$ info symbol 0x188f048
  badf_errcnt.5450.0.13 in section .bss of /sites/eqx/work/swcores/tripunjay/F10ACOREDIR/f10cp_sshd.login-eqx-06.6402/sshd
  gdb$ p &amp;badf_errcnt
  No symbol "badf_errcnt" in current context.
  gdb$ select-frame 5
  gdb$ frame         
  Stack level 5, frame at 0xbb4aca20:
   eip = 0x1846007 in wait_until_can_do_something (serverloop.c:404); saved eip 0x1846698
   called by frame at 0xbb4b0af0, caller of frame at 0xbb4ac9d0
   source language c.
   Arglist at 0xbb4aca18, args: readsetp=0xbb4b0ab4, writesetp=0xbb4b0ab8, maxfdp=0x4, nallocp=0xbb4b0abc, max_time_milliseconds=0x0
   Locals at 0xbb4aca18, Previous frame's sp is 0xbb4aca20
   Saved registers:
    ebx at 0xbb4aca00, ebp at 0xbb4aca18, esi at 0xbb4ac9fc, edi at 0xbb4aca04, eip at 0xbb4aca1c
  readsetp = 0xbb4b0ab4
  writesetp = 0xbb4b0ab8
  maxfdp = 0x4
  nallocp = 0xbb4b0abc
  max_time_milliseconds = 0x0
  badf_errcnt = &lt;optimized out&gt;
  tv = &lt;optimized out&gt;
  tvp = &lt;optimized out&gt;
  client_alive_scheduled = 0x0
  gdb$ p &amp;badf_errcnt
  Can't take address of "badf_errcnt" which isn't an lvalue.
  </code></pre>