title: Why is this pointer null
body: <p>In Visual Studio, it seems like pointer to member variables are 32 bit signed integers behind the scenes (even in 64 bit mode), and a null-pointer is -1 in that context. So if I have a class like:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;cstdint&gt;
  
  struct Foo
  {
      char arr1[INT_MAX];
      char arr2[INT_MAX];
      char ch1;
      char ch2;
  };
  
  
  int main()
  {
      auto p = &amp;Foo::ch2;
      std::cout &lt;&lt; (p?&quot;Not null&quot;:&quot;null&quot;) &lt;&lt; '\n';
  }
  </code></pre>
  <p>It compiles, and prints &quot;null&quot;. So, am I causing some kind of undefined behavior, or was the compiler supposed to reject this code and this is a bug in the compiler?</p>
  <p>Edit:</p>
  <p>It appears that I can keep the &quot;2 <code>INT_MAX</code> arrays plus 2 chars&quot; pattern and only in that case the compiler allows me to add as many members as I wish and the second character is always considered to be null. <a href="https://godbolt.org/z/foxYW8" rel="noreferrer">See demo</a>. If I changed the pattern slightly (like 1 or 3 chars instead of 2 at some point) it complains that the class is too large.</p>