openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

ofColor undefined behavior

Open dimitre opened this issue 1 year ago • 3 comments

today I was analyzing code in XCode with address sanitizer on, undefined behavior sanitizer and it indicates an UB on ofColor

Screenshot 2024-10-31 at 00 03 17
ofColor.cpp:172:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
ofColor.cpp:172:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
ofColor.cpp:172:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
ofColor.cpp:172:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
setFbo 

and another one in ofGLProgrammableRenderer::draw

Screenshot 2024-10-31 at 00 05 59

dimitre avatar Oct 31 '24 03:10 dimitre

not sure why the ofColor_ constructor takes floats instead of PixelType. I would assume it is because of that.

roymacdonald avatar Oct 31 '24 16:10 roymacdonald

@roymacdonald I thought the same. @NickHardeman any downside of using PixelType as the template parameter?

dimitre avatar Oct 31 '24 20:10 dimitre

@dimitre I can't think of any.... Not sure about the programmable renderer, all of those values in the if statement are bools

NickHardeman avatar Nov 01 '24 13:11 NickHardeman