http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

            Bug ID: 60809
           Summary: C99 struct initialiser with embedded self assignment
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jimis at gmx dot net

For the following code, which was a typo from my side (full example attached):

<pre>
        struct addrinfo query2 = {
                .ai_family = AF_UNSPEC,
                .ai_socktype = SOCK_STREAM,
                query2.ai_flags = AI_PASSIVE
        };
</pre>

1. A warning would be nice, something like "suggest parentheses around
assignment"
2. What is the C99 mandated behaviour? I'm not sure GCC is behaving properly.
Currently it sets ai_protocol to 1 because it is the next field after
ai_socktype. But it also sets ai_flags to 1, which I'd expect to be 0 after the
outer struct initialiser is executed.


See discussion, full example program and output, at
http://gcc.gnu.org/ml/gcc-help/2014-04/msg00033.html

Reply via email to