title: unpredictable behavior of Inline functions with different definitions
body: <p>I have the following source files:</p>
  
  <pre><code>//test1.cpp
  #include &lt;iostream&gt;
  using namespace std;
  
  inline void foo()
  {
    cout &lt;&lt; "test1's foo" &lt;&lt; endl;
  }
  
  void bar();
  
  int main(int argc, char *argv[])
  {
    foo();
    bar();
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>//test2.cpp
  #include &lt;iostream&gt;
  
  using namespace std;
  
  inline void foo()
  {
      cout &lt;&lt; "test2's foo" &lt;&lt; endl;
  }
  
  void bar()
  {
      foo();
  }
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>test1's foo
  test1's foo
  </code></pre>
  
  <p>Huh??? Ok, so I should have declared the foos static... but shouldn't this kind of thing generate a linker error, or at least a warning? And how does the compiler "see" the inline functions from across compilation units?</p>
  
  <p>EDIT: This is using gcc 4.4.1.</p>