You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interpolation algorithm implemented in C works fine in debug configurations, but failed to generate the correct output when compiler optimizations were enabled with -O2.
Demo
Using lena32.bmp as input for simplicity, 2x magnification.
Debug
Release
With -O2, only the last row, which is the first row to be generated, was correct. The rest of the image was blank.
Possible causes
It's clear that the optimizations introduced unexpected behaviors to the algorithm. After some searching, the absence of the volatile keyword might be to blame. Refer to How to Use C's volatile Keyword for more info.
The text was updated successfully, but these errors were encountered:
It's been verified that using volatile keyword in every declaration related to loops could fix the problem. Whether it is necessary or not is not tested yet.
Description
The interpolation algorithm implemented in C works fine in debug configurations, but failed to generate the correct output when compiler optimizations were enabled with
-O2
.Demo
Using
lena32.bmp
as input for simplicity, 2x magnification.Debug
Release
With
-O2
, only the last row, which is the first row to be generated, was correct. The rest of the image was blank.Possible causes
It's clear that the optimizations introduced unexpected behaviors to the algorithm. After some searching, the absence of the
volatile
keyword might be to blame. Refer to How to Use C's volatile Keyword for more info.The text was updated successfully, but these errors were encountered: