title: Why is this generic expression bugging out?
body: <p>Recently I answered some <a href="https://stackoverflow.com/questions/35646493/const-correctness-in-c99">question</a> asking how to implement complex const correctness of a structure member. Doing this I used Generic expressions and encountered strange behavior. Here is the sample code:</p>
  
  <pre><code>struct A
  {
      union {
          char *m_ptrChar;
  
          const char *m_cptrChar;
      } ;
  };
  
  #define ptrChar_m(a) _Generic(a, struct A *: a-&gt;m_ptrChar,        \
                                   const struct A *: a-&gt;m_cptrChar,  \
                                   struct A: a.m_ptrChar,        \
                                   const struct A: a.m_cptrChar)
  
  void f(const struct A *ptrA)
  {
      ptrChar_m(ptrA) = 'A'; // NOT DESIRED!!
  }
  </code></pre>
  
  <p>On GCC and Clang the generic expression select the case when the type of <code>a</code> must be <code>struct A</code> which doesn't make any sense. When I comment the last two cases though it's working fine. Why is this - is it some bug?</p>
  
  <p>The exact error messages on clang are:</p>
  
  <pre><code>test.c:17:5: error: member reference type 'const struct A *' is a pointer; did you mean to use '-&gt;'?
      ptrChar_m(ptrA) = 'A'; // NOT DESIRED!!
      ^
  test.c:12:45: note: expanded from macro 'ptrChar_m'
                                   struct A: a.m_ptrCHar,        \
                                              ^
  test.c:17:5: error: member reference type 'const struct A *' is a pointer; did you mean to use '-&gt;'?
      ptrChar_m(ptrA) = 'A'; // NOT DESIRED!!
      ^
  test.c:13:51: note: expanded from macro 'ptrChar_m'
                                   const struct A: a.m_cptrChar)
                                                    ^
  test.c:17:21: error: cannot assign to variable 'ptrA' with const-qualified type 'const struct A *'
      ptrChar_m(ptrA) = 'A'; // NOT DESIRED!!
                      ^
  test.c:15:24: note: variable 'ptrA' declared const here
  void f(const struct A *ptrA)
                         ^
  test.c:23:18: error: invalid application of 'sizeof' to a function type [-Werror,-Wpointer-arith]
      return sizeof(main);
  4 errors generated.
  </code></pre>