From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5ZTC-0002gV-Nu for qemu-devel@nongnu.org; Fri, 20 Oct 2017 11:44:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5ZT9-0004wY-KZ for qemu-devel@nongnu.org; Fri, 20 Oct 2017 11:44:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36866) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5ZT9-0004w1-ES for qemu-devel@nongnu.org; Fri, 20 Oct 2017 11:44:19 -0400 References: <20171020101219.2378-1-pbonzini@redhat.com> <9695ca9b-6275-d7bf-1c3b-147aeab25473@redhat.com> From: Paolo Bonzini Message-ID: Date: Fri, 20 Oct 2017 17:44:13 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek , Peter Maydell Cc: QEMU Developers On 20/10/2017 17:32, Laszlo Ersek wrote: > On 10/20/17 17:09, Paolo Bonzini wrote: >> On 20/10/2017 17:08, Laszlo Ersek wrote: >>> My remark below might matter even less, but: >>> >>> I'd find it regrettable if we suppressed a wrong gcc warning about a >>> valid C construct by replacing the construct with a GNU-ism that is >>> *not* standard C. :/ >> >> Is {} to initialize structs a GNUism? > > It is; > >> struct { >> int a, b; >> } x = {}; > > $ gcc -fsyntax-only -std=c99 -pedantic -Wall -Wextra x.c > >> x.c:3:7: warning: ISO C forbids empty initializer braces [-Wpedantic] >> } x = {}; >> ^ >> x.c:3:1: warning: missing initializer for field 'a' of 'struct ' [-Wmissing-field-initializers] >> } x = {}; >> ^ >> x.c:2:7: note: 'a' declared here >> int a, b; >> ^ > > If you replace "{}" with "{ 0 }", the same command line stays quiet. > > (I used: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16).) Oh. So there _was_ some logic to my original configure patch. Currently we have 82 occurrences of empty initializers and 92 occurrences of {0}, so I think it makes sense to go ahead with it. On the other hand, without a more precise option than -Wpedantic, empty initializers are going to creep in again. Paolo