Why is this piece of code working in Visual Studio Express 2012?
struct S{int k;};
int main(S s)
{
s.k = 100;
// other lines
}
I read both the standards document and MSDN but didn't find any mention of prohibiting this kind of overloads of main
although this MSDN page says nothing more than Cannot be overloaded . Does that imply it is allowed if the implementation likes it? Or it is simply a bug in the compiler?
From what I gather from the initial comments to this question, and the discussion in the question this is marked duplicate of, suitable overloads are allowed by the implementation as long as the canonical ones are supported. However, of what use is it to allow the kind of overload that I mention? The environment has no idea of the structure to populate it and pass it as the argument during start up. Shouldn't it be a bug?
There may be an obscure (from my POV) situation where the program may be loaded by custom loader which sets up the arguments etc. Is that the reason this is allowed?