Closed fedegiova closed 3 years ago
Hi @fedegiova , thanks for figuring out the root cause of this issue.
When you say, "disabling optimizations locally," do you mean that you disable optimizations for TRex, and still enable optimizations for the entire application? Did you do it by using some #pragma directives? Is it an acceptable solution for you?
Hi, with the attribute below the optimizations getsl disabled only for the function trex_compile
, all the others get the optimization level specified on the command line.
TREX_API TRex* trex_compile(const TRexChar* pattern, const TRexChar** error, int flags) __attribute__((optimize(0)));
I've not found another way to force the variable to be allocated on the stack and not on the registers, unfortunately setjump saves only PC and SP so when returning from a longjmp call the values of the other registers are incoherent.
@fedegiova Thanks for this solution. I don't want to change the TRex implementation, so I will add the attribute to trex_compile
when we compile with GCC.
I got this error while compiling with
-Wall
on an ARM target:The problem in in the function trex_compile which uses setjmp() to handle errors, on posix
man setjmp
states:I've not found any way to satisfy the above requirements without changing the function signature, but I've solved the error disabling optimizations locally, this way the compiler (gcc 9.2) put the variable on the stack and the error get resolved.
At the function declaration:
I'm filing an issue because maybe someone has a better idea.