public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "petr.pisar at atlas dot cz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/64480] New: List designated initializer triggers -Wmissing-field-initializers
Date: Sat, 03 Jan 2015 15:27:00 -0000	[thread overview]
Message-ID: <bug-64480-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64480

            Bug ID: 64480
           Summary: List designated initializer triggers
                    -Wmissing-field-initializers
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: petr.pisar at atlas dot cz

This code:

struct lower {
    char *foo;
    char *bar;
};

struct upper {
    struct lower inner;
};

int main (void) {
    struct upper u = {
        /* This triggers -Wmissing-field-initializers warning */
        .inner.foo = "Foo",
        .inner.bar = "Bar",

        /* While this passes: 
        .inner = {
            .foo = "Foo",
            .bar = "Bar",
        },
        */
    };

    (void)u;

    return 0;
}


Triggers warning about initialized lower.bar field:

$ gcc -Wall -Wextra -std=c99 -O0 -g test.c
test.c: In function ‘main’:
test.c:14:9: warning: missing initializer for field ‘bar’ of ‘struct lower’
[-Wmissing-field-initializers]
         .inner.bar = "Bar",
         ^
test.c:3:11: note: ‘bar’ declared here
     char *bar;
           ^

If I change to initialization from the list form (.inner.foo=) to nested
(.inner={.foo=}), then it passes. The change is commented out in the quoted
code.

I think the list syntax is valid per C99, 6.7.9 Initialization grammar.
>From gcc-bugs-return-472115-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 03 15:48:02 2015
Return-Path: <gcc-bugs-return-472115-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21225 invoked by alias); 3 Jan 2015 15:48:02 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21084 invoked by uid 48); 3 Jan 2015 15:47:57 -0000
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60255] [OOP] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
Date: Sat, 03 Jan 2015 15:48:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: janus at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P4
X-Bugzilla-Assigned-To: vehre at gmx dot de
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: keywords bug_status assigned_to short_desc
Message-ID: <bug-60255-4-o8WgMQtiqr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60255-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60255-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-01/txt/msg00109.txt.bz2
Content-length: 771

https://gcc.gnu.org/bugzilla/show_bug.cgi?id`255

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |vehre at gmx dot de
            Summary|[oop] Deferred character    |[OOP] Deferred character
                   |length variable at (1)      |length variable at (1)
                   |cannot yet be associated    |cannot yet be associated
                   |with unlimited polymorphic  |with unlimited polymorphic
                   |entities                    |entities


             reply	other threads:[~2015-01-03 15:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-03 15:27 petr.pisar at atlas dot cz [this message]
2015-01-05 15:26 ` [Bug c/64480] " joseph at codesourcery dot com
2015-01-05 15:30 ` mpolacek at gcc dot gnu.org
2015-09-18  9:44 ` mpolacek at gcc dot gnu.org
2023-04-06  8:48 ` zhonghao at pku dot org.cn
2023-04-06  9:28 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64480-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).