<div dir="auto">Thanks guys, the issue is resolved now. It was a more trivial fix. Gcc was not giving any error neither on compile time nor on run time. Clang was giving error on runtime. <div dir="auto">It was an issue with a function which was supposed to return a Boolean but it wasn't. I could not figure it out earlier because debugging was not working. But when I got it working I could pinpoint the function, someone from llvm-dev thread suggested to check for such a function. So, finally it got fixed. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Aug 29, 2017 12:13 AM, "John McCall via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Aug 27, 2017, at 7:11 PM, Csaba Raduly via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hi,<br>
> foo() has undefined behavior if i==0 (lack of return statement)<br>
><br>
> 6.6.3 para 2:<br>
> Flowing off the end of a function is equivalent to a return with no<br>
> value; this results in undefined behavior<br>
> in a value-returning function.<br>
><br>
> clang generates an invalid instruction for undefined behavior.<br>
> This is not ARM-specific.<br>
<br>
Note that this is C++-specific; it is only undefined behavior in C if the result is used by the caller.<br>
<br>
John.<br>
<br>
><br>
> <a href="https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,source:'int+foo(int+i)+%7B%0A+if(i)+%7B%0A+++return+1%3B%0A+%7D%0A%7D%0A%0Aint+main()+%7B%0A+foo(0)%3B%0A%7D%0A'),l:'5" rel="noreferrer" target="_blank">https://godbolt.org/#g:!((g:!(<wbr>(g:!((h:codeEditor,i:(j:1,<wbr>source:'int+foo(int+i)+%7B%0A+<wbr>if(i)+%7B%0A+++return+1%3B%0A+<wbr>%7D%0A%7D%0A%0Aint+main()+%7B%<wbr>0A+foo(0)%3B%0A%7D%0A'),l:'5</a>',<wbr>n:'0',o:'C%2B%2B+source+%231',<wbr>t:'0')),k:50,l:'4',n:'0',o:'',<wbr>s:0,t:'0'),(g:!((h:compiler,i:<wbr>(compiler:clang400,filters:(__<wbr>_0:(),b:'0',commentOnly:'0',<wbr>directives:'0',intel:'0',<wbr>jquery:'3.2.1',length:1,<wbr>prevObject:(___0:(),length:1,<wbr>prevObject:(___0:(<wbr>jQuery3210202339019067484751:(<wbr>display:'')),length:1)),trim:'<wbr>0'),options:'-O0',source:1),l:<wbr>'5',n:'0',o:'x86-64+clang+4.0.<wbr>0+(Editor+%231,+Compiler+%231)<wbr>',t:'0')),k:50,l:'4',n:'0',o:'<wbr>',s:0,t:'0')),l:'2',n:'0',o:''<wbr>,t:'0')),version:4<br>
><br>
> That ud2 instruction is the machine code for undefined behavior.<br>
><br>
> Csaba<br>
><br>
><br>
> On Sat, Aug 26, 2017 at 12:32 PM, Raphael Isemann via cfe-dev<br>
> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
>> Glad to help. CCing ML for the record.<br>
>><br>
>> On Aug 26, 2017 12:24 PM, "ROHIT KUMAR" <<a href="mailto:rohitpoddar92@gmail.com">rohitpoddar92@gmail.com</a>> wrote:<br>
>><br>
>> It is as you mentioned. The missing return statement in a function very much<br>
>> similar to your example. Adding it fixed the issue<br>
>><br>
>> So, it seems Clang is a little too strict as compared to GCC. I faced many<br>
>> issues earlier and all of them ended up being related to flags, I didn't<br>
>> expect the issue to be this simple.<br>
>><br>
>> Thanks for your help<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> On Sat, Aug 26, 2017 at 3:14 PM, Raphael Isemann <<a href="mailto:teemperor@gmail.com">teemperor@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> On a side note that is probably too simple for the ML: Did you check<br>
>>> for missing return statements in the called/callee function? For a<br>
>>> missing return clang generates SIGILL while GCC is returning something<br>
>>> ABI-dependent IIRC.<br>
>>><br>
>>> E.g. this causes SIGILL on clang and runs just fine on GCC:<br>
>>> ```<br>
>>> int foo(int i) {<br>
>>> if(i) {<br>
>>>   return 1;<br>
>>> }<br>
>>> }<br>
>>><br>
>>> int main() {<br>
>>> foo(0);<br>
>>> }<br>
>>> ```<br>
>>><br>
>>> - Raphael<br>
>>><br>
>>><br>
>>> 2017-08-26 10:34 GMT+02:00 ROHIT KUMAR via cfe-dev<br>
>>> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>>:<br>
>>>> Hey folks,<br>
>>>><br>
>>>> I am migrating our huge Android code base from GCC(Eclipse IDE) to<br>
>>>> clang(Android Studio).<br>
>>>><br>
>>>> Error: SIGILL (signal SIGILL: illegal instruction)<br>
>>>><br>
>>>> At a weird line in the code, I am getting this error. which points to a<br>
>>>> closing curly bracket of an if condition. After googling, I am assuming<br>
>>>> it<br>
>>>> is some kind of architecture flag issue. I am using same flags which<br>
>>>> were<br>
>>>> used for GCC.<br>
>>>><br>
>>>> Note: I am currently working on Arm build.<br>
>>>><br>
>>>> Here are the architecture flags for ARM7:<br>
>>>><br>
>>>> -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mtune=cortex-a8<br>
>>>> -mthumb<br>
>>>> -DTARGET_THUMB2<br>
>>>><br>
>>>> Can anyone help me debug this issue? Is there any issue with the flags<br>
>>>> with<br>
>>>> clang?<br>
>>>><br>
>>>> Thanks,<br>
>>>> Rohit Kumar<br>
>>>><br>
>>>><br>
>>>><br>
>>>> ______________________________<wbr>_________________<br>
>>>> cfe-dev mailing list<br>
>>>> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
>>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
>>>><br>
>><br>
>><br>
>><br>
>><br>
>> ______________________________<wbr>_________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++<br>
> The Tao of math: The numbers you can count are not the real numbers.<br>
> Life is complex, with real and imaginary parts.<br>
> "Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds<br>
> "People disagree with me. I just ignore them." -- Linus Torvalds<br>
> ______________________________<wbr>_________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>