I would like to add to the answers already given by citing the actual language standards.
Is ‘int main;’ a valid C program?
Short answer (my opinion): only if your implementation uses a "freestanding execution environment".
All following quotes from C11
5. Environment
An implementation translates C source files and executes C programs in
two dataprocessing-system environments, which will be called the
translation environment and the execution environment [...]
5.1.2 Execution environments
Two execution environments are defined: freestanding and hosted. In
both cases, program startup occurs when a designated C function is
called by the execution environment.
5.1.2.1 Freestanding environment
In a freestanding environment (in which C program execution may take
place without any benefit of an operating system), the name and type
of the function called at program startup are implementation-defined.
5.1.2.2 Hosted environment
A hosted environment need not be provided, but shall conform to the
following specifications if present.
5.1.2.2.1 Program startup
The function called at program startup is named main. [...] It shall
be defined with a return type of int and with no parameters [...] or
with two parameters [...] or equivalent or in some other
implementation-defined manner.
From these, the following is observed:
- A C11 program can have a freestanding or a hosted execution environment and be valid.
- If it has a freestanding one, there need not exist a main function.
- Otherwise, there must be one with a return vale of type int.
In a freestanding execution environment, I would argue that it is a valid program that does not allow startup to happen, because there is no function present for that as required in 5.1.2.
In a hosted execution environment, while your code introduces an object named main, it cannot provide a return value, so I would argue that it is not a valid program in this sense, although one could also argue like before that if the program is not meant to be executed (on might want to provide data only for example), then it just does not allow to do just that.
Is ‘int main;’ a valid C++ program?
Short answer (my opinion): only if your implementation uses a "freestanding execution environment".
Quote from C++14
3.6.1 Main function
A program shall contain a global function called main, which is the
designated start of the program. It is implementation-defined whether
a program in a freestanding environment is required to define a main
function. [...] It shall have a return type of type int, but otherwise
its type is implementation-defined. [...] The name main is not
otherwise reserved.
Here, as opposed to the C11 standard, less restrictions apply to the freestanding execution environment, as no startup function is mentioned at all, while for a hosted execution environment, the case is pretty much the same as for C11.
Again, I would argue that for the hosted case, your code is not a valid C++14 program, but I am sure that it is for the freestanding case.
Since my answer only considers the execution environment, I think the answer by dasblinkenlicht comes into play, as name mangling occuring in the translation environment happens beforehand. Here, I am not so sure that the quotes above are observed so strictly.