<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 9/12/13 2:04 PM, Matthew Curtis
      wrote:<br>
    </div>
    <blockquote cite="mid:52322C6F.1020008@codeaurora.org" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 9/11/2013 2:30 PM, Eli Friedman
        wrote:<br>
      </div>
      <blockquote
cite="mid:CAJdarcEMSnXCJeCO9VaW93enN34gmgqufUUP9Bo3V-PkGvDs6w@mail.gmail.com"
        type="cite">
        <div dir="ltr">On Wed, Sep 11, 2013 at 6:10 AM, Matthew Curtis <span
            dir="ltr"><<a moz-do-not-send="true"
              href="mailto:mcurtis@codeaurora.org" target="_blank">mcurtis@codeaurora.org</a>></span>
          wrote:<br>
          <div class="gmail_extra">
            <div class="gmail_quote">
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
                0.8ex;border-left:1px solid
                rgb(204,204,204);padding-left:1ex">I'm investigating an
                assert in clang compiling the following code:<br>
                <br>
                  typedef union {<br>
                    struct {<br>
                      int zero;<br>
                      int one;<br>
                      int two;<br>
                      int three;<br>
                    } a;<br>
                    int b[4];<br>
                  } my_agg_t;<br>
                <br>
                  my_agg_t agg_instance =<br>
                  {<br>
                    .b[0] = 0,<br>
                    .a.one = 1,<br>
                    .b[2] = 2,<br>
                    .a.three = 3,<br>
                  };<br>
                <br>
                I'm a little uncertain as to what this *should* do.<br>
                <br>
              </blockquote>
              <div>This is also <a moz-do-not-send="true"
                  href="http://llvm.org/bugs/show_bug.cgi?id=16644">http://llvm.org/bugs/show_bug.cgi?id=16644</a>
                .<br>
                <br>
              </div>
              <div>I would say we should either use gcc's interpretation
                or reject it.<br>
                <br>
              </div>
              <div>-Eli <br>
              </div>
            </div>
          </div>
        </div>
      </blockquote>
      <br>
      Sounds reasonable. Unless someone has a dissenting opinion, I'll
      look at fixing this by making clang consistent with gcc.<br>
      <br>
      Thanks,<br>
      Matthew Curtis<br>
    </blockquote>
    I would argue somewhat strongly against adopting gcc's
    interpretation.  I'm not going to get into the specification debate
    - I'll leave that to others who are more knowledgeable - but the gcc
    behavior is highly unintuitive.  <br>
    <br>
    The closest code analogy I could think of would be this:<br>
    my_agg_t agg;<br>
    (agg.b[0] = 0, agg.a.one = 1, agg.b[2] = 2, agg.a.three = 3); <br>
    printf("%d, %d, %d, %d\n", agg.a.zero, agg.a.one, agg.a.two,
    agg.a.three);<br>
    <br>
    I tried this code with both clang and gcc at various levels of
    optimization and got the same result: "0, 1, 2, 3".  I expect
    getting any other results would be considered unintuitive at the
    least by most programmers.  <br>
    <br>
    Given that these code fragments are obvious candidates for manual
    "refactoring" moving from c++03 to c++11, this unintuitive
    difference seems particularly problematic.  <br>
    <br>
    Yours,<br>
    Philip Reames<br>
    <br>
    <br>
  </body>
</html>