[cfe-dev] Question about compiling exit and clang assert

Peter Lawrence via cfe-dev cfe-dev at lists.llvm.org
Sun Jul 23 11:04:07 PDT 2017


I have a simulator for a target machine that I wrote an llvm port for
The simulator detects a return to address zero as returning from “main"
and that ends the simulation, with main's return value then being printed out
(and finally returned from the simulator to the shell).

I tried to implement “exit” in C rather than in assembly with the following


void * __builtin_frame_address (unsigned int level);

int exit (int X)
{
	((int*)__builtin_frame_address(0))[1] = 0; // simulator termination magic
	return X; // put result code in R0, as though returning X from main
}


After some warnings about redeclaration and about noreturn
clang crashes with an assert,

So my question is, isn’t the clang assertion too conservative ?
Why crash after warnings, why not let it go through ?


TIA,
Peter Lawrence.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170723/4bbf7e5e/attachment.html>


More information about the cfe-dev mailing list