<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 1, 2012 at 1:04 PM, Gisle Vanem <span dir="ltr"><<a href="mailto:gvanem@broadpark.no" target="_blank">gvanem@broadpark.no</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">These gcc extensions:<br></blockquote><div> </div><div>Hi, Gisle!</div>
<div><br></div><div>I'm happy to open another ticket for these, but have you tried using the bugtracker yourself? Is there some UI issue or something that prevents you from opening tickets?  If so I'd be glad to try to help work around it, but if not it's really more convenient to have bugtracker tickets to discuss this stuff.</div>
<div><br></div><div>As for the patch, I don't think it's a good idea as-is, for two reasons:</div><div>  * First, the syntax there is *NOT* a GCC extension; it's a standard C99 feature.</div><div>  * Second, the workaround is error-prone.  If the fields in the structure are ever designated in an order that doesn't match their declaration order in the structure definition, we'll get a situation where C99-compliant compilers generate the code as intended, but where non-C99-compliant compilers fail, or worse-- generate different code.  To be concrete, consider this example: </div>
<div><br></div><div><div>#include <stdio.h></div><div><br></div><div>struct X {</div><div>  const char *important;</div><div>  const char *actor;</div><div>  const char *victim;</div><div>};</div><div><br></div><div>
#if I_HAVE_C99</div><div>  #define STRUCT_INIT(member,val) member = val</div><div>#else</div><div>  #define STRUCT_INIT(member,val) val</div><div>#endif</div><div><br></div><div>int main(int argc, char **argv)</div><div>{</div>
<div>  struct X y = {</div><div>    STRUCT_INIT(.actor, "vendors"),</div><div>    STRUCT_INIT(.victim, "programmers"),</div><div>    STRUCT_INIT(.important, "Standards")</div><div>  };</div><div>
  printf("%s are important.\n"</div><div>    "When %s support them, that makes life easier for %s.\n",</div><div>         y.important, y.actor, y.victim);</div><div>  return 0;</div><div>}</div></div><div>
<br></div><div>So I think the better fix there is probably to verify that the designated initializers are indeed given in the structure declaration order, and then to simply replace them with comments.  It's not as good as it would be if we could rely on having a C99 compiler (in 2012), but it's better that risking our code behaving differently on C99 and non-C99 compilers.</div>
<div><br></div><div>yrs,</div><div>-- </div><div>Nick</div></div><br></div>