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 11:33:52




>> On Jan 21, 2014, at 5:11 PM, "Ville Voutilainen" <ville.voutilainen_at_[hidden]> wrote:
>>
>> On 22 January 2014 02:55, David Krauss <david_work_at_[hidden]> wrote:
>> 1. Violation of “shall” is diagnosable unless otherwise specified (1.4/1).
>
> Ok. I don't think this is obviously clear.
>
>> 2. I would take “use” to mean ODR-use.
>
> I wouldn't, I would take "use" to mean any use, not just odr-use.
>
>> 3. Far as I know, the implementation is allowed to perform dynamic initialization of globals in main. So for all intents and purposes, it’s not really usable as a function because its body doesn’t describe what it does.
>
> Well, apparently some implementations think they can get away with it
> under the auspices
> of undefined behavior. :)

That is just plain implementation bug; don't let an implementer impress you with appeal to undefined behavior on this one :-)

-- Gaby


SG12 list run by herb.sutter at gmail.com