C++ Logo

SG12

Advanced search

Subject: Re: [ub] What does "The function main shall not be used within a program" mean?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2014-01-22 17:02:01


> On Jan 22, 2014, at 2:51 PM, "Ville Voutilainen" <ville.voutilainen_at_[hidden]> wrote:
>
>>>> I don’t recall ever seeing an implementation not to allow safe recursion
>>>> of main. Often the C runtime
>>> gcc doesn't allow it if given -pedantic.
>> Clang trunk also doesn't allow it with -pedantic-errors. Both GCC and Clang
>> reject decltype(main()) too, in strictly-conforming mode. EDG rejects
>> odr-uses of main but accepts uses that are not odr-uses.
>
> It seems that gcc still allows this lovely piece of shenanigans:
>
> int main() {int y = sizeof(decltype(main)*);}
>
>
> Should this be a core issue?

why isn't it a gcc bug instead? Clearly it doesn't implement the rule consustently.

-- Gaby


SG12 list run by herb.sutter at gmail.com