From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by sourceware.org (Postfix) with ESMTPS id F03C83858C30 for ; Tue, 10 Oct 2023 17:38:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F03C83858C30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-5a7c93507d5so8308387b3.2 for ; Tue, 10 Oct 2023 10:38:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696959534; x=1697564334; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7iM7y3Ocgl94Z7ZQF5UCENMg/+sl0hhYAvwG/T+9rDc=; b=DSbgmfhSwpTBwLd+4BlUIESfiOMSCp7NrRnXWMran+slZNejDMtq/pALDXVa+RVZkX m/uzxsQGt8cWMlEeeoAIonzVcyqXa9XsHgjkgTOyD5YYK9xuF/Jih4lleIdk7knsUb0b qS0ODpU8Ya5SKv8QyPNqvlqAG3SSojU4VZUU1kcDHWmxIZHPD46UQBpHeLhLub80wFYJ hlWxM7oZe/HH94Kn1mH/3eipaxYre5FV4F5nXsDkGpFCca5KAieFw26mYSt5Ty8WSNlU PIUyQM3NQ5565EgdHc1MmkK76UR077X7eBVID2mLIhY6nCcMbsCAM8G+yKVgXcTpjwcT s02g== X-Gm-Message-State: AOJu0YyH8Mjo25+7ZxZlFA1q/IEXWctGfF7M/vMKraJqDVfgbXcjoO87 Qlr8xfPprOpC2vdpgJIwblz+uiZFKQw= X-Google-Smtp-Source: AGHT+IFX+2Eycw2PZbvuP9tR/l114m/L3U0awOE7gA6WkqrDizM437Nsqa/IK3gZiXRLEwjhXTupuw== X-Received: by 2002:a81:9a09:0:b0:5a7:aaac:2bce with SMTP id r9-20020a819a09000000b005a7aaac2bcemr4566201ywg.35.1696959534024; Tue, 10 Oct 2023 10:38:54 -0700 (PDT) Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com. [209.85.128.171]) by smtp.gmail.com with ESMTPSA id w129-20020a817b87000000b00589c103d00asm4551009ywc.79.2023.10.10.10.38.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Oct 2023 10:38:53 -0700 (PDT) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-59f6e6b206fso74473637b3.3 for ; Tue, 10 Oct 2023 10:38:53 -0700 (PDT) X-Received: by 2002:a0d:fd43:0:b0:58c:6121:48e8 with SMTP id n64-20020a0dfd43000000b0058c612148e8mr21210540ywf.33.1696959532947; Tue, 10 Oct 2023 10:38:52 -0700 (PDT) MIME-Version: 1.0 References: <87h6myaf6b.fsf@oldenburg.str.redhat.com> <87y1ga8kzz.fsf@oldenburg.str.redhat.com> In-Reply-To: <87y1ga8kzz.fsf@oldenburg.str.redhat.com> Reply-To: joel@rtems.org From: Joel Sherrill Date: Tue, 10 Oct 2023 12:38:40 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: C89 question: Do we need to accept -Wint-conversion warnings To: Florian Weimer Cc: Jakub Jelinek , Jason Merrill , gcc@gcc.gnu.org Content-Type: multipart/alternative; boundary="00000000000028e1c10607602e25" X-Spam-Status: No, score=-3031.3 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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: --00000000000028e1c10607602e25 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Oct 10, 2023 at 12:09=E2=80=AFPM Florian Weimer via Gcc wrote: > * Jakub Jelinek: > > > On Tue, Oct 10, 2023 at 12:30:52PM -0400, Jason Merrill via Gcc wrote: > >> On Tue, Oct 10, 2023 at 7:30=E2=80=AFAM Florian Weimer via Gcc > > >> wrote: > >> > >> > Are these code fragments valid C89 code? > >> > > >> > int i1 =3D 1; > >> > char *p1 =3D i; > >> > > >> > char c; > >> > char *p2 =3D &c; > >> > int i2 =3D p2; > >> > > >> > Or can we generate errors for them even with -std=3Dgnu89? > >> > > >> > (It will still be possible to override this with -fpermissive or > >> > -Wno-int-conversion.) > >> > > >> > >> Given that C89 code is unlikely to be actively maintained, I think we > >> should be permissive by default in that mode. People compiling with an > old > >> -std flag are presumably doing it to keep old code compiling, and it > seems > >> appropriate to respect that. > > > > Yeah, complete agreement here. > > Okay. It helps with the test suite conversation because -std=3Dgnu89 -w > is available today, so I can post such patches separately. > > >> I'm also (though less strongly) inclined to be permissive in C99 mode, > and > >> only introduce the new strictness by default for C11/C17 modes. > > > > Especially when the default is -std=3Dgnu17 that can be an option as we= ll. > > > > There might be some code in the wild compiled with -std=3Dgnu99 or > -std=3Dc99 just > > because it wanted to use C99 features back 15-20 years ago and hasn't > been > > adjusted since then, but it might be better to adjust that if needed and > keep > > using those flags only when they are needed because the code isn't > C11/C17/C2X > > ready. > > Linux currently uses -std=3Dgnu99 deliberately in a few places, I believe. > It would be a shame if we defaulted to permissive mode over there. I > would certainly prefer to restrict permissive mode to the C89/C90 > language levels. We can have this discussion once I post my patch > (which depends on Jason's permerror enhancement in several ways). > C99 is what POSIX assumes up to the next version which should be nearing release. It moves the baseline to C11. Also from a safety critical system viewpoint, C99 (and C++03) was still widely used. In fact the FACE Technical Standard gave only those language versions for application conformance purposes. C++11 and C++14 were very recently added as options in a corrigenda that was released in August. I know this isn't the primary focus for GCC but embedded isn't rare. =46rom an RTEMS perspective, the OS is primarily built as C11 but that was primarily done for access to the atomics defined there not in C99. So it isn't that the code "isn't ready" for a new language version, it may be because there are standards still based on older versions or the safety review process may not accommodate a newer version. It also could be as simple as the RTOS vendor does not recommend using it with their OS which has been through something like a flight qualification. --joel > > Thanks, > Florian > > --00000000000028e1c10607602e25--