public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: Ville Voutilainen <ville.voutilainen@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	       Jason Merrill <jason@redhat.com>
Subject: Re: [C++ Patch] PR 67065 ("Missing diagnostics for ill-formed program with main variable instead of function")
Date: Wed, 19 Aug 2015 20:42:00 -0000	[thread overview]
Message-ID: <55D4E8FB.8040305@oracle.com> (raw)
In-Reply-To: <CAFk2RUb3UTLMS4WyT=urHYURSzaahq+qRU1rE0QNroGkxTCwug@mail.gmail.com>

Hi,

On 08/19/2015 10:33 PM, Ville Voutilainen wrote:
> On 19 August 2015 at 23:26, Paolo Carlini <paolo.carlini@oracle.com> 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.

  reply	other threads:[~2015-08-19 20:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19 20:27 Ville Voutilainen
2015-08-19 20:28 ` Paolo Carlini
2015-08-19 20:37   ` Ville Voutilainen
2015-08-19 20:42     ` Paolo Carlini [this message]
2015-08-19 21:46       ` Ville Voutilainen
  -- strict thread matches above, loose matches on Subject: below --
2015-08-19 19:52 Paolo Carlini
2015-08-20  2:35 ` Jason Merrill
2015-08-21  6:30 ` Markus Trippelsdorf
2015-08-21  7:47   ` Markus Trippelsdorf
2015-08-21  9:07     ` Paolo Carlini
2015-08-21  9:22       ` Paolo Carlini
2015-08-21  9:29         ` Markus Trippelsdorf
2015-08-21 12:57           ` Paolo Carlini
2015-08-21 15:44         ` Jason Merrill
2015-08-21 17:22           ` Paolo Carlini
2015-08-21 17:37             ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55D4E8FB.8040305@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=ville.voutilainen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).