From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 261B93858D37 for ; Thu, 29 Sep 2022 07:12:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 261B93858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664435531; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=01RNn0vKEDkAwsG1Mbp9kBPtKQbE7JKvZZj4DAvBpl4=; b=emwMzI79BwfmP9er36O6urVbqZWSZa4QHJabhthswmgoG3FoZj1y64Lo0Jk0ZMJthTgw81 V9HqGL5lW6hhXLWaNbdy42hvMmKZUGc/xHuaAsjfj0KPP6nn8UwOvsEBHxgBSlhmeqY6mW e/lwiF6kCjVpiPpjt3e+cin2gmUqgrc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-wOT5V0IVM4aG7q3bmpAaYw-1; Thu, 29 Sep 2022 03:12:06 -0400 X-MC-Unique: wOT5V0IVM4aG7q3bmpAaYw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63A3938173CB; Thu, 29 Sep 2022 07:12:06 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 257FA40EFB1A; Thu, 29 Sep 2022 07:12:06 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28T7C3wD3886860 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Sep 2022 09:12:04 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28T7C3R33886859; Thu, 29 Sep 2022 09:12:03 +0200 Date: Thu, 29 Sep 2022 09:12:02 +0200 From: Jakub Jelinek To: Richard Biener Cc: Jonathan Wakely , "gcc@gcc.gnu.org" Subject: Re: Handling of main() function for freestanding Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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 Thu, Sep 29, 2022 at 08:00:15AM +0200, Richard Biener via Gcc wrote: > On Wed, Sep 28, 2022 at 10:17 PM Jonathan Wakely via Gcc > wrote: > > > > As part of implementing a C++23 proposal [1] to massively increase the > > scope of the freestanding C++ standard library some questions came up > > about the special handling of main() that happens for hosted > > environments. > > > > As required by both C++ (all versions) and C (since C99), falling off > > the end of the main() function is not undefined, the compiler is > > required to insert an implicit 'return 0' [2][3]. However, this > > special handling only applies to hosted environments. For freestanding > > the return type or even the existence of main is > > implementation-defined. > ^^^^^^^^^^^^^^^^^^^^^^ > > so just document that 'int main(int, char **)' is special to GCC even in > freestanding environments and do not emit -Wreturn-type diagnostics? > I think that's entirely reasonable (but of course make sure to add > an implicit return 0; then as well) -fspecial-main is weirdly named, I wonder if we couldn't do the above by default and have -fno-builtin-main turn that special behavior off (in that case then don't append return 0 and emit -Wreturn-type diagnostics). Not all our builtins are about whether we expand them inline, but about whether we apply special handling to those functions, assume special properties etc. Just -fno-builtin shouldn't imply -fno-builtin-main... Jakub