<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I have a simulator for a target machine that I wrote an llvm port for<div class="">The simulator detects a return to address zero as returning from “main"</div><div class="">and that ends the simulation, with main's return value then being printed out</div><div class="">(and finally returned from the simulator to the shell).</div><div class=""><br class=""></div><div class="">I tried to implement “exit” in C rather than in assembly with the following</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">void * __builtin_frame_address (unsigned int level);</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 21px;" class=""><br class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">int exit (int X)</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>((int*)__builtin_frame_address(0))[1] = 0; // simulator termination magic</div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>return X; // put result code in R0, as though returning X from main</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><br class=""></div><div class="">After some warnings about redeclaration and about noreturn</div><div class="">clang crashes with an assert,</div><div class=""><br class=""></div><div class="">So my question is, isn’t the clang assertion too conservative ?</div><div class="">Why crash after warnings, why not let it go through ?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">TIA,</div><div class="">Peter Lawrence.</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>