This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pstorage_clear return with gcc compiler -o1 but -o3

I found a strange phenomenon with sdk 8.1.

If I use arm gcc compiler to compile code containing pstorage operation, functions like pstorage_clear will not return though the call back function is still called.

Finally, I found if the optimize option is changed from -o3 to -o1, pstorage_clear will work well.

But the Keil compiler works well even with option -o3 for the same code.

So it might be caused by the difference between the optimize option (like -o2) of the two compilers? But I don't know what exacactly is.

BTW, Keil uses --c99 and gcc uses --std=gnu99.

Parents
  • Okay, I found the reason. That's caused by the while loop after pstorage_clear, when using -o3, the while loop is optimized as a infinite loop though the test condition would change at some time. So I add keyword "volitale" to the while loop test variable definition, and fix it. For GCC, it's not a reasonable optimization since the test variable is global and would change at some place.

Reply
  • Okay, I found the reason. That's caused by the while loop after pstorage_clear, when using -o3, the while loop is optimized as a infinite loop though the test condition would change at some time. So I add keyword "volitale" to the while loop test variable definition, and fix it. For GCC, it's not a reasonable optimization since the test variable is global and would change at some place.

Children
No Data
Related