Class defined in different translation units
<p>As I have understood, a class can be defined in multiple translation units aslong they're identical. With that in mind, consider the following examples:</p>

<pre><code> //1.cpp

class Foo{
 public:
  int i;
};


void FooBar();

void BarFoo(){
  Foo f;
}


int main(){
 FooBar();
 BarFoo();
}

//2.cpp

class Foo{
 public:
  std::string s;
};

void FooBar(){
  Foo f;
}
</code></pre>

<p>This compiles and I don't get a crash.</p>

<p>If I do the following changes:</p>

<pre><code>//1.cpp
 Foo FooBar();
//2.cpp
 Foo FooBar(){
   Foo f;
   return f;
 }
</code></pre>

<p>I get a crash. Why does one result in a crash and the other doesn't. Also, am I not violating ODR in the first example? If I am, why does it compile ok?</p>
