From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81151 invoked by alias); 19 Aug 2015 20:37:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 81141 invoked by uid 89); 19 Aug 2015 20:37:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 19 Aug 2015 20:37:22 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t7JKbJG6030271 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Aug 2015 20:37:19 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t7JKbIag008376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 19 Aug 2015 20:37:19 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t7JKbIO0012887; Wed, 19 Aug 2015 20:37:18 GMT Received: from [192.168.1.4] (/79.37.218.190) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Aug 2015 13:37:18 -0700 Subject: Re: [C++ Patch] PR 67065 ("Missing diagnostics for ill-formed program with main variable instead of function") To: Ville Voutilainen References: <55D4E690.7020703@oracle.com> Cc: "gcc-patches@gcc.gnu.org" , Jason Merrill From: Paolo Carlini Message-ID: <55D4E8FB.8040305@oracle.com> Date: Wed, 19 Aug 2015 20:42:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg01139.txt.bz2 Hi, On 08/19/2015 10:33 PM, Ville Voutilainen wrote: > On 19 August 2015 at 23:26, Paolo Carlini wrote: >> Hi Ville, >> >> >> On 08/19/2015 10:12 PM, Ville Voutilainen wrote: >>>> submitter noticed that, in violation of [basic.start.main], we don't >>>> reject >>>> as ill-formed the declaration of a 'main' variable in the global >>>> namespace. >>>> Not a big deal IMHO, but the below simple check works well for me on >>>> x86_64-linux. >>> Just fyi, gcc accepts >>> >>> decltype(main) x; >>> >>> decltype(sizeof(decltype(main)*)) x; >>> >>> which are "uses" of main and also violate [basic.start.main]/3. >> "good" to know. In my experience sometimes the front end appears to >> so-to-speak pre-declare entities. For instance I filed a while ago >> c++/48396. Not sure if in practice the exact same code is involved... > Let me clarify: this is not about that. It's code like > > int main() {} > > decltype(main) x; > > whereas just having > > decltype(main) x; > > as the whole program will diagnose the use of an undeclared > identifier. Nevertheless, > no use, not just odr-use, but use of main as in the entry point > pseudo-function is allowed > by the standard, but gcc allows some of them. gcc rejects attempts to > call main even in > such decltype contexts, but it can be fooled to allow other uses of main. Ah, Ok, I didn't actually try to compile your snippet. Then I suspect you mean c++/66606?!? Please double check if something is missing in Martin's bug! Paolo.