FLTK logo

STR #3199

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

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:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#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 ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.