Question about compiling exit and clang assert

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 ?

Peter Lawrence.

Ooops, my apologies for that question. my target, like MSP430 has 16-bit ints,
but unlike MSP430, does not support 32-bit ints at all, so the actual crash
is in the call to __builtin_frame_address(0) which expects i32, but is being
passed i16 because that’s all my target supports.

If I change clang so that __builtin_frame_address / __builtin_return_address
take “native” size ints rather than being hard wired to i32
is that the sort of thing that a patch would be accepted for ?

Peter Lawrence.