C++ Logo

sg12

Advanced search

Re: [ub] What does "The function main shall not be used within a program" mean?

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 22 Jan 2014 08:13:47 +0200
On 22 January 2014 03:08, Stephen Clamage <stephen.clamage_at_[hidden]> wrote:
> Historically, function main in C++ often needed to perform some magic,
> and the actual implementation of main might not behave in the same way
> as an ordinary function with the same definition. If you could declare
> or call main, or take its address, results would be unpredictable. Thus,
> the restrictive rules allow main to be special, where needed.
>
> If you want a recursive main, or want to *do* something with it, you can
> write mymain as an ordinary function, and have the real main just call
> it. Example, for the case of using only argc and argv:

I don't want a recursive main. I want such shenanigans to be ill-formed.
Implementations don't seem to agree, and I want to know whether
our current wording intends such things to be ill-formed or UB.

Received on 2014-01-22 07:13:48