This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch] PR 67065 ("Missing diagnostics for ill-formed program with main variable instead of function")


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]