| [ Return to Bugs & Features | Roadmap 1.3 | SVN ⇄ GIT ]
STR #3199
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 2 - Specific to an operating system |
Subsystem: | Core Library |
Summary: | Compiler warning: array subscript is above array bounds (Windows) |
Version: | 1.3-current |
Created By: | AlbrechtS |
Assigned To: | AlbrechtS |
Fix Version: | 1.3.4 (SVN: v10593) |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | AlbrechtS 08:51 Feb 26, 2015 |
| I found these new warnings when compiling under Windows/Cygwin with gcc 4.8.3:
In file included from fl_draw_image.cxx:30:0: fl_draw_image_win32.cxx: In function ‘void innards(const uchar*, int, int, int, int, int, int, int, Fl_Draw_Image_Cb, void*)’: fl_draw_image_win32.cxx:147:22: warning: array subscript is above array bounds [-Warray-bounds] bmi.bmiColors[i].rgbBlue = (uchar)i; ^ fl_draw_image_win32.cxx:148:22: warning: array subscript is above array bounds [-Warray-bounds] bmi.bmiColors[i].rgbGreen = (uchar)i; ^ fl_draw_image_win32.cxx:149:22: warning: array subscript is above array bounds [-Warray-bounds] bmi.bmiColors[i].rgbRed = (uchar)i; ^ fl_draw_image_win32.cxx:150:22: warning: array subscript is above array bounds [-Warray-bounds] bmi.bmiColors[i].rgbReserved = (uchar)0; // must be zero ^
... lots more warnings of same type, lines 147 to 150.
Compiling with gcc 4.8.1 (MinGW) doesn't show these warnings. | |
|
#2 | AlbrechtS 09:09 Feb 26, 2015 |
| According to MS docs there is an array with only one array element, but in fact it is an array of a varying number of elements at the end of the structure. https://msdn.microsoft.com/en-us/library/windows/desktop/dd183375%28v=vs.85%29.aspx
typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO, *PBITMAPINFO;
The array in question is bmiColors[1]. | |
|
#3 | AlbrechtS 09:10 Feb 26, 2015 |
| Fixed in Subversion repository.
The fix is to use a pointer to suppress array bounds checking. | |
[ Return to Bugs & Features ]
|
| |