From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NOR01-OL1-obe.outbound.protection.outlook.com (mail-ol1nor01on2071.outbound.protection.outlook.com [40.107.224.71]) by sourceware.org (Postfix) with ESMTPS id 9D9833858C52 for ; Wed, 11 Oct 2023 07:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D9833858C52 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=westcontrol.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=westcontrol.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eoMweuomoKFkyzwQl85z05u/yhpdbugApoTf7Y5jANysc5J9YtVur8sAypoL8kD111lw5Rkz/2AGlyHsH7ajtYgZ6iSRytKCgNfCMc9udZjpVe3V1evpwMyv5PYUFe0D4wcRzNxqwqOnsZ0w5yVgpSUyypZ+dAXdTes4s72dx0EWCFW2HVbQIdeZ4iNzO3LBGnu27UplWlaxbqhRYLCP73HjrGalecgJ+pzX8DcUEx9Ep6JJIMrvbYcxDLR5wOz4td84WlJb8M5thx68Y9LNeZsslJjKt0FDzMAxMQyntDMxzc/T1pJpogcDtlw7K9cJ+sYU2KlIx031YqaFV53+QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yBqCOPXBYRV/BtX4IPaE6A4qO7unnVxBnWHkMkuvzEs=; b=AmpzhyEROT4cOcINKz2dSPm6Z66FOr/izb2E84Fl4/1HUfqG/mJqkqsMojA3N4tY+OvNtP///rmtvm1aqbgO1aDcYcktL34SYsPix3eFwABqRQRrlYLb1xKiRHCblm7b68tf+jALy1poPJmzeLP1vTMMPK1aenduUG8SZ+0b75Kh6U4nFaLdKejeKKksg2l0SotDigoTOLk8Go2bWp0VG6yf7YnHNJmOtOy0AFF53SSVEYwMfCina+r4jdvzJsTXdG1PZyEzLskgiDWyT2K8PnEaLv8/+U9+ZVdKGYxLXZc9kNI4kYqF6psEXLEtBGtYcNiiWWGs+vLxmklEEWIJGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=westcontrol.com; dmarc=pass action=none header.from=westcontrol.com; dkim=pass header.d=westcontrol.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=westcontrol.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yBqCOPXBYRV/BtX4IPaE6A4qO7unnVxBnWHkMkuvzEs=; b=VwWP9pRXMkFmrjcm0cGaq7JK+l64mBPBdNf3TcQEP0tcgaA3hYOzV3vVWzea6eKq2IP3gWCvTJm33Fkn6au0vRaVwusrAGK9hksl0+dpeYtfqrM7Z9pY+85zanExs0d0U0ZTFssxAbTaV+kzHxVT5lMXHf9nrtT9KLN38nZAAyvEY4kvxN42nXvYZYKMDaUXV96m0727VdGSeq6Rhk6k8I8YoA+akwHlPb3XVVc3znp7MTtQplSr3PD6QKpHZR6un2IK09+zgPMXVIF9sc8j2xl4F4UN1uYQJlzSSt3Vy+aAocLTaTAxsJTeuqsLOvVWtctSnXf6JHjbRKMztzUdWw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=westcontrol.com; Received: from SV0P279MB0233.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:b::13) by OS6P279MB0746.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:44::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.43; Wed, 11 Oct 2023 07:36:33 +0000 Received: from SV0P279MB0233.NORP279.PROD.OUTLOOK.COM ([fe80::1e40:a4aa:a2b2:3c70]) by SV0P279MB0233.NORP279.PROD.OUTLOOK.COM ([fe80::1e40:a4aa:a2b2:3c70%4]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 07:36:33 +0000 Message-ID: <75b14d17-896c-db03-fad1-1931f39533e6@westcontrol.com> Date: Wed, 11 Oct 2023 09:36:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: C89 question: Do we need to accept -Wint-conversion warnings Content-Language: en-GB To: Jason Merrill , Florian Weimer Cc: gcc@gcc.gnu.org References: <87h6myaf6b.fsf@oldenburg.str.redhat.com> From: David Brown In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SV0P279CA0016.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:11::21) To SV0P279MB0233.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:b::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SV0P279MB0233:EE_|OS6P279MB0746:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e1a80b7-8cc1-489b-8130-08dbca2cca91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JkDM9p6tVWRn9zcjtH5OJbS0m1rbwKsVGPXClKImFt+h8a2t9oqWVOe3yKzdf7X0rrMBIV4UWfxIsyalKTBbZAY4x1UREOEHlpYrV1GwDnt2NcclwVMjYjdrhBFeQeKWFzfB5qGLAZGb6igP2/OhuoxeS8jQGl3pHHc2d1smqxYeA8WyC5FY0OZU45fdnI8OAX1z8zaWk7bKtfM0JlCgWeEUFq3iwCE05Zy0adj77u98i0Oq5mQkTQe9p6HtefsHqlL7AUfvB7NeYFMdbcC91waT/ZrOUtrZ0BxNSAfSCRFhkHCEiEdjKJDV6+dkNolKqWzcnPjZ+nDE9chykIJ8ADw5Vpk3Nta0vZZYKsZvGbNUcrb4o7odKs4ass9UD3oJgysKWEnIa5l/OqJA53pWNffKgbvuDv0ifOiOWeViZY1cfZpLI1E+WbapdXmqW2cJFa+nmK6t0vkO4vnPGdQXmBpTQDjZi8Hf9GpvUWYzX5ruq5lIiE1IQHIdYeump0vYcfmmtgiHrQpi3gwKTvSwx91fVRSIZNlT1+43/pllfhKbk+c7MTtutCDcZCatxiUe0qLwkEXCyRRAZyDso44uF4q/AWzKyD6/33zlA6VNJofDTYdtqcq8IqiWSyooenRWZ0rsOBLXR4Ms4CrVlHFqnw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SV0P279MB0233.NORP279.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(376002)(39840400004)(136003)(366004)(396003)(346002)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(2616005)(83380400001)(31686004)(26005)(66899024)(6512007)(5660300002)(66556008)(66476007)(316002)(8676002)(8936002)(4326008)(38100700002)(2906002)(66946007)(110136005)(41300700001)(478600001)(36756003)(6506007)(45080400002)(53546011)(6486002)(31696002)(86362001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T0Jqajg0M3pQdnVyMUhPUzhEakdRWGxXdDdJQ2cxVlB2Wk0yME1rMGp5NkR3?= =?utf-8?B?R2U1K3ZVSjNxS21jeVo1MzlZUzZKRkt4WEtUblMvdVl3YmhxYldwUHF5R0Mz?= =?utf-8?B?dDZ2SE51c1o2NXBtMEtJZWMyUVhVWjZYYzNmUFN4RFljSUVzWDNWajNzekds?= =?utf-8?B?NW5jQnIzcHdTWUNGMGd4YzlGMnA1OWUzbGpCL0RLODZkVW1IVnRHNm5SbzJ4?= =?utf-8?B?cVFTSndQd1JiMUsxRWM0Y0hLaWJTV2NSUXV0dG12YnlWVS9kd0dnZ2hWb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NFllbEwwbVpsK0Vma2o4NTh5QWZCN1JiWDAzUDdPc0FEUDVj?= =?utf-8?Q?Fcn7s4+Er1SxR68QIH5+MhlfO?= X-OriginatorOrg: westcontrol.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e1a80b7-8cc1-489b-8130-08dbca2cca91 X-MS-Exchange-CrossTenant-AuthSource: SV0P279MB0233.NORP279.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 07:36:33.1437 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c75fbd3c-42ad-4db0-9cff-972faf83ae45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nzzi0yUSb6wIN5SqlCfomRfGfhjfl/qJei0lRSNfrQKgu0oKZ+oAknFVGkcsj99YFzBr93/MbLJbx8wKLkb2xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS6P279MB0746 X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP 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 10/10/2023 18:30, Jason Merrill via Gcc wrote: > On Tue, Oct 10, 2023 at 7:30 AM Florian Weimer via Gcc > wrote: > >> Are these code fragments valid C89 code? >> >> int i1 = 1; >> char *p1 = i; >> >> char c; >> char *p2 = &c; >> int i2 = p2; >> >> Or can we generate errors for them even with -std=gnu89? >> >> (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. > That is - unfortunately, IMHO - not true. In particular, in the small-systems embedded development world (and that is a /big/ use-case for C programming), there is still a lot done in C89/C90. It is the dominant variety of C for things like RTOS's (such as FreeRTOS and ThreadX), network stacks (like LWIP), microcontroller manufacturers' SDK's and libraries, and so on. There are also still some microcontrollers for which the main toolchains (not GCC, obviously) do not have full C99 support, and there is a significant proportion of embedded C programmers who write all their code in C90, even for new projects. There is a "cult" within C coders who think "The C Programming Language" is the "Bible", and have never learned anything since then. The biggest target device in this field is the 32-bit ARM Cortex-M family, and the the most used compiler is gcc. Taking numbers out of thin air, but not unrealistically I believe, there are millions of devices manufactured every day running code compiled by gcc -std=gnu89 or -std=c89 (or an equivalent). Add to that the libraries on "big" systems that are written to C89/C90 standards. After all, that is the lowest common denominator of the C/C++ world - with a bit of care, the code will be compatible with all other C and C++ standards. It is not just of old code, though a great deal of modern library code has roots back to pre-C99 days, but it is also cross-platform code. It is only relatively recently that Microsoft's development tools have had reasonable support for C99 - many people writing code to work in both the *nix world and the Windows world stick to C89/C90 if they want a clear standard (rather than "the subset of C99 supported by the MSVC version they happen to have"). Now, pretty much all of that code could also be compiled with -std=c99 (or -std=gnu99). And in a great many cases, it /is/ compiled as C99. But for those that want to be careful about their coding, and many do, the natural choice here is "-std=c90 -pedantic-errors". So IMHO (and as I am not a code contributor to GCC, my opinion really is humble) it is better to be stricter than permissive, even in old standards. It is particularly important for "-std=c89", while "-std=gnu89" is naturally more permissive. (I have seen more than enough terrible code in embedded programs - I don't want to make it easier for them to write even worse code!) > 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. > I suspect (again with numbers taken from thin air) that the proportion of C programmers or projects that actively choose C11 or C17 modes, as distinct from using the compiler defaults, will be less than 1%. C99 (or gnu99) is the most commonly chosen standard for small-systems embedded programming, combining C90 libraries, stacks, and RTOS's with user code in C99. So again, my preference is towards stricter control, not more permissive tools. I am aware, however, that I personally am a lot fussier than most programmers. I run gcc with lots of additional warnings and -Wfatal-errors, and want ever-stricter tools. I don't think many people would be happy with the choices /I/ would prefer for default compiler flags! I am merely a happy GCC user, not a contributor, much less anyone involved in decision making. But I hope it is helpful to you to hear other opinions here, especially about small-systems embedded programming, at least in my own experience. David