From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.schemamania.org (rrcs-50-75-19-234.nys.biz.rr.com [50.75.19.234]) by sourceware.org (Postfix) with ESMTP id D510B385702B for ; Wed, 10 May 2023 23:18:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D510B385702B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=schemamania.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=schemamania.org Received: from oak.schemamania.org (localhost [IPv6:::1]) by mail.schemamania.org (Postfix) with ESMTP id 3EAF2256FAB6; Wed, 10 May 2023 14:37:50 -0400 (EDT) Date: Wed, 10 May 2023 14:37:50 -0400 From: "James K. Lowden" To: gcc@gcc.gnu.org Cc: Jonathan Wakely Subject: Re: More C type errors by default for GCC 14 Message-Id: <20230510143750.417de4d214583a398737337f@schemamania.org> In-Reply-To: References: <877cth66qb.fsf@oldenburg.str.redhat.com> <20230509102201.6aa2a7d14fdb2f1e7abff449@killthe.net> <87r0rp5uf8.fsf@aarsen.me> <83ttwla1ep.fsf@gnu.org> <83lehx9vix.fsf@gnu.org> <83fs859unu.fsf@gnu.org> X-Mailer: Sylpheed 3.4.3 (GTK+ 2.24.28; x86_64--netbsd) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06,KAM_DMARC_STATUS,KAM_NUMSUBJECT,NICE_REPLY_A,RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 9 May 2023 23:45:50 +0100 Jonathan Wakely via Gcc wrote: > On Tue, 9 May 2023 at 23:38, Joel Sherrill wrote: > > We are currently using gcc 12 and specifying C11. To experiment > > with these stricter warnings and slowly address them, would we need > > to build with a newer C version? > > No, the proposed changes are to give errors (instead of warnings) for > rules introduced in C99. GCC is just two decades late in enforcing the > C99 rules properly! This, it seems to me, is the crux of the question. Code that does not conform to the standard should produce an error. Code that can be compiled correctly, per the specification, but might not be what the user intended, is a candidate for a warning. If the proposed changes catch true errors -- not just dubious constructs -- that were previously allowed, well, that's the price of progress. That's the compiler getting better at distinguishing between code conformant and not. Section 2.1 "C Language" of the manual states that, with no option specified on the command line, the default standard is -std=gnu17. Part of the proposal IIUC is to treat undeclared functions as an error. Function prototypes have been required afaik since c99. If that's correct, then letting them pass without error is a mistake for -std=c99 and above. As to the default, is anyone suggesting that gnu17 -- i.e., c17 with GNU extensions -- includes ignoring missing function prototypes? That to me would be an odd definition of "extension". The user who has old code that does not meet the c99 standard but Just Works nonetheless has a direct route to compiling that code without complaint: -std=c90. It says so right there in the fine manual. It's that simple. The code is either in spec and compiles without error, or it is not and does not. The only debate is over what "the spec" is, and what warnings the user might want for conforming code. --jkl