I am trying to run an example introduced by optimization manual(June 2013) on page 11-23, example 11-14. I tried to use a separate .s file to write the function, and a main.c file to do the main func. The code will only run correctly in debug mode. Please see attachment for my code. The cond_loop.c is actually cond_loop.s but the forum won't accept this kind of extension.
- icc main-2.c cond_loop.s -g Everything works fine.
- icc main-2.c cond_loop.s Segmentation Fault with failure to access array members at the end of the code.
After the function void cond_loop(const float *a, float *b, const float *c, const float *d, const float *e, const int length) returns, all the array pointers will be lost so I cannot access the old arrays anymore. This problem will only occur without -g compile option, meaning release code only bug. So I am not able to debug it. I did some research and it showed this is because in debug mode stack frame pointer will always be saved but in release mode this is not the case. I am not sure this is my problem and I don't really know how to solve the problem. I tried to push rbp and rsp but these won't help. Would anyone please help me look at it? Any advice is appreciated. Thank you all!
BTW: in attachment, cond_loop_c.c is the corresponding C version of the assembly and of course, this one works perfectly. And I am using Linux so it is X64 system V ABI. Thanks again.