This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does g++ really need to compile main, if c++ code is involved?


On 20 March 2014 15:50, Eric Wolf wrote:
>
> I really think, static initializations and exceptions are the problem,
> because if I placed main in a C source file and compile it with gcc,
> how are the initializations done? How are uncaught exceptions handled?

Using the DWARF-based exception mechanism the compiler looks up the
stack for a suitable catch handler and if none is found (either
because the higher stack frames are C++ functions but don't catch the
exception, or because they are not C++ functions at all) then
std::terminate() is called at the throw site.

So I believe an uncaught exception will terminate the process
irrespective of what language main() is written in.

Global ctors/dtors are a separate issue, I'm not sure how they're
handled if main() isn't written in C++.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]