public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60784] New: Spurious -Wmissing-field-initializers warning for anonymous structure
@ 2014-04-07 22:23 peter at lekensteyn dot nl
  2014-04-08  6:54 ` [Bug c/60784] " mpolacek at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: peter at lekensteyn dot nl @ 2014-04-07 22:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60784
           Summary: Spurious -Wmissing-field-initializers warning for
                    anonymous structure
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: peter at lekensteyn dot nl

When an anonymous structure gets initialized, gcc always starts complaining
about the last field:
//////////////////////////////////////////
gcc -Wextra warn.c -o /dev/null
//////////////////////////////////////////
struct foo {
    struct {
        char a;
        char b;
    };
};

int main(void) {
    struct foo test = {
        .a = 1,
        .b = 2,
    };

    return test.a == 1;
}
///////////////////////////////////////////

Output:
warn.c: In function ‘main’:
warn.c:12:9: warning: missing initializer for field ‘b’ of ‘struct <anonymous>’
[-Wmissing-field-initializers]
         .b = 2,
         ^
warn.c:5:14: note: ‘b’ declared here
         char b;
              ^

It gets even worse when adding more fields. For fun, add "char c;" between
"char a;" and "char b;". The first warning mentions "c", but the line
thereafter points to "b":
warn.c: In function ‘main’:
warn.c:13:9: warning: missing initializer for field ‘c’ of ‘struct <anonymous>’
[-Wmissing-field-initializers]
         .b = 2,
         ^
warn.c:5:14: note: ‘c’ declared here
         char c;
              ^

Expected result: no warnings for the first case.

This is gcc-multilib 4.8.2-8 on Arch Linux x86_64.

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-4.8-20140206/configure
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --disable-cloog-version-check --enable-lto
--enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu
--enable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.8.2 20140206 (prerelease) (GCC)
>From gcc-bugs-return-448493-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Apr 07 22:47:04 2014
Return-Path: <gcc-bugs-return-448493-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22347 invoked by alias); 7 Apr 2014 22:47:04 -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 22297 invoked by uid 48); 7 Apr 2014 22:47:01 -0000
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/60657] [4.9 Regression] ICE: error: insn does not satisfy its constraints
Date: Mon, 07 Apr 2014 22:47:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: ice-on-invalid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: law at redhat dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P1
X-Bugzilla-Assigned-To: law at redhat dot com
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60657-4-Wkbk8sLam9@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60657-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60657-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: 2014-04/txt/msg00513.txt.bz2
Content-length: 415

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`657

--- Comment #13 from Jeffrey A. Law <law at redhat dot com> ---
The new predicates make the predicate test match the constraint test.   It
looks like your patch exposes a relationship between the operands, and, yes,
the only way to handle that would be in the insn's condition.

I'm not ARM savvy enough to know if that's the right condition or not though.

jeff


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-12-12 12:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-07 22:23 [Bug c/60784] New: Spurious -Wmissing-field-initializers warning for anonymous structure peter at lekensteyn dot nl
2014-04-08  6:54 ` [Bug c/60784] " mpolacek at gcc dot gnu.org
2014-04-10 20:43 ` mpolacek at gcc dot gnu.org
2014-04-13 15:04 ` mpolacek at gcc dot gnu.org
2014-05-02  5:41 ` mpolacek at gcc dot gnu.org
2014-05-02  5:42 ` mpolacek at gcc dot gnu.org
2014-12-12 10:31 ` peter at lekensteyn dot nl
2014-12-12 12:28 ` peter at lekensteyn dot nl

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).