From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 97D3F3857016 for ; Wed, 10 May 2023 23:27:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97D3F3857016 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-50bd37ca954so73914136a12.0 for ; Wed, 10 May 2023 16:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683761225; x=1686353225; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dW1zRwyviwFYQrbm0Fsl+Q1amjOGIhoibEvWMW+dt2g=; b=BwDGCKV07qDNmYpyKkxkLrctaRMENbeSvoo8fQVCLOmqKgInNx9eMPty6K+k7vAgGZ sC5Q3qJPlWlsg7zVnkknu+fuS6VE6G4dG2gu1r9dUdeI9thf925+7WB8PypqJz8cS8ah rqfS8/4/Agys9PMwtqoj8BqhQ2Jz0MvBvyYJgrs0naBjaarMljoonNGNtpOtIXOgawuQ AXM/V/rW9kXP2HjaLzwdM4Mqo4PEJaGl/sbJVMe+Nqob48+29Z4zW/dRQhtLBmbYvU0Y ivgosHG2TGOhs0SU72nYTHmQNMhVB1/BD6TIRrrZ1hQzXKAaZQQYpHF4yJbxJEMUrE80 qz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683761225; x=1686353225; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dW1zRwyviwFYQrbm0Fsl+Q1amjOGIhoibEvWMW+dt2g=; b=g5tiWaD3qbWjSpXSYSPawt6TEZ8Q/e1H0yaRIEltxLSwuZZGjcBxw0rqaHuVt5kn7A y5sU/TyHtydNdMuMprrjI5GNro5Sk7FA57eJ0jX84jytrOfy0PnB+tQjsraYdAjbRcdX 0iFW8Mp9ooHOCz/2QoUz58zjL00kaK/+3E3WKiwB7MS6QPVVbvFdUwlqMmDdfWvfMxkh dHi14o3SsFzG3LyoK5kv3xuvIOg7+GMnNID36IC/llTxWl5nO3E4BsH/ybnSXjDlUi9T ppp7vXL41iK4tQwsr+C2imDoWGWK6tgoT4kam21xTZW4CwAEtlIRmJwcV492Td7YleTO jvEg== X-Gm-Message-State: AC+VfDxaF/TUMl4L+7Mag18hb2Ah2ArG2os79ggwJzidhCbYhlj6XpMU +FSy48aXObFEyLFT02Qur/iT4ad6ee2oRrB9Opy+PAWk X-Google-Smtp-Source: ACHHUZ5hIMJ9pdpWDbUMzvojRmxnval+FBT1f7nElnR1nbE281sa7Eb5lRIn9xchZk1AeErsjrG8vMGHw9adIQHXzlI= X-Received: by 2002:a17:907:7e96:b0:966:1ab0:94de with SMTP id qb22-20020a1709077e9600b009661ab094demr14940211ejc.18.1683761225092; Wed, 10 May 2023 16:27:05 -0700 (PDT) MIME-Version: 1.0 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> <20230510143750.417de4d214583a398737337f@schemamania.org> In-Reply-To: <20230510143750.417de4d214583a398737337f@schemamania.org> From: Jonathan Wakely Date: Thu, 11 May 2023 00:26:53 +0100 Message-ID: Subject: Re: More C type errors by default for GCC 14 To: "James K. Lowden" Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, 11 May 2023 at 00:18, James K. Lowden wrote: > > 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. That's not what the standard says. > 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. Technically, the standard only requires a diagnostic, and a warning is a diagnostic. So strictly speaking, it's conforming to let them pass with a warning. The question is whether that's really the best behaviour for the majority of current users. At some point in the past it was decided that warning and continuing by default was the best choice. That might not still be true today. > 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". I don't think that actually matters here. > 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. Indeed. > 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. Well, no, because issuing a warning for violations of the spec conforms to the standard. So it's not that simple, we really do have to decide whether to actually cause compilation failure for these constraint violations, or just issue a diagnostic and continue.