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
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
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 ` mpolacek at gcc dot gnu.org
2014-04-10 20:43 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-04-08 6:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-04-08
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
.b = X is designated initializer and -Wmissing-field-initializers shouldn't
warn for them.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
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
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-04-10 20:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This regtested/bootstrapped patch fixes it, but I'm not fully confident it's
the Right Place. The problem is that constructor_designated wasn't set
properly when entering pop_init_level from c_parser_braced_init, since
push_init_level called earlier set it to 0.
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 65aad45..9813698 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -7750,6 +7750,7 @@ set_init_label (tree fieldname, struct obstack *
braced_init_obstack)
do
{
constructor_fields = TREE_VALUE (field);
+ constructor_designated = 1;
designator_depth++;
designator_erroneous = 0;
if (constructor_range_stack)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
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
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-04-13 15:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Target Milestone|--- |4.10.0
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Potential fix: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00623.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
2014-04-07 22:23 [Bug c/60784] New: Spurious -Wmissing-field-initializers warning for anonymous structure peter at lekensteyn dot nl
` (2 preceding siblings ...)
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
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-05-02 5:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Fri May 2 05:40:38 2014
New Revision: 209998
URL: http://gcc.gnu.org/viewcvs?rev=209998&root=gcc&view=rev
Log:
PR c/60784
* c-typeck.c (push_init_level): Set constructor_designated to
p->designated for structures.
* gcc.dg/pr60784.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/pr60784.c
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
2014-04-07 22:23 [Bug c/60784] New: Spurious -Wmissing-field-initializers warning for anonymous structure peter at lekensteyn dot nl
` (3 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-05-02 5:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Should be fixed now.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
2014-04-07 22:23 [Bug c/60784] New: Spurious -Wmissing-field-initializers warning for anonymous structure peter at lekensteyn dot nl
` (4 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: peter at lekensteyn dot nl @ 2014-12-12 10:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
--- Comment #7 from Peter Wu <peter at lekensteyn dot nl> ---
This bug is still present in GCC 4.9.2 and 4.9.3 (prerelease 20141210). Now
building gcc-5-20141207 to verify. (Not sure whether this gets backported to
4.9.x, just checking.)
//////////////////////////////////////////
gcc -Wextra bug.c -o /dev/null
//////////////////////////////////////////
typedef struct HidppMessage {
struct {
int feature_index;
int func;
};
} HidppMessage;
int main(void) {
HidppMessage req = {
.feature_index = 0xFF,
.func = 1
};
return req.func;
}
//////////////////////////////////////////
Strange enough, replacing 0xFF by 0x00 hides the warning.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60784] Spurious -Wmissing-field-initializers warning for anonymous structure
2014-04-07 22:23 [Bug c/60784] New: Spurious -Wmissing-field-initializers warning for anonymous structure peter at lekensteyn dot nl
` (5 preceding siblings ...)
2014-12-12 10:31 ` peter at lekensteyn dot nl
@ 2014-12-12 12:28 ` peter at lekensteyn dot nl
6 siblings, 0 replies; 8+ messages in thread
From: peter at lekensteyn dot nl @ 2014-12-12 12:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
--- Comment #8 from Peter Wu <peter at lekensteyn dot nl> ---
GCC 5 is OK, the question is whether 4.9 will or will not receive a fix?
^ 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).