public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/10185: Wrong code with 3-int-structs & optimization
@ 2003-03-21 15:16 rassahah
0 siblings, 0 replies; only message in thread
From: rassahah @ 2003-03-21 15:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 10185
>Category: optimization
>Synopsis: Wrong code with 3-int-structs & optimization
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Fri Mar 21 15:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Rasmus Hahn
>Release: gcc-3.3, gcc-3.4 cvs
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
the how to repeat program should scan a list of some 3-int-structs for members with a specific depth and maximal bits_per_pixel field, and fails.
Insertion of a dummy function-call (printf in how-to-repeat) or changing the size of the struct makes the program work (as does compiling without optimization).
Suspect this has to to with i386-specific optimization for multiplying by 3, 5 or more with lea-instruction when indexing the array.
this bug is in my Versions of gcc:
gcc version 3.4 20030321 (experimental)
gcc version 3.3 20021104 (experimental)
when compiling with -O2.
>How-To-Repeat:
typedef struct {
int depth, bits_per_pixel, scanline_pad;
/* change size by adding another int, removing one & it works, add 2 or more and it wont */
} XPixmapFormatValues;
XPixmapFormatValues *XListPixmapFormats (int *i);
main () /* compile with -O2 */
{
XPixmapFormatValues *pfm;
int i, bpp = 0;
pfm = XListPixmapFormats (&i); /* returns 3 in i */
while (i--) {
//printf ("a"); /* comment this in & it works */
if ((pfm[i].depth == 24) && (pfm[i].bits_per_pixel > bpp)) {
bpp = pfm[i].bits_per_pixel;
}
}
if (bpp < 8) { abort (); /* should not abort */ }
}
/* dummy version of X-Function for testing */
XPixmapFormatValues * XListPixmapFormats (int *i)
{
static XPixmapFormatValues rv[3] = {
{16, 16, 32}, {24, 32, 32}, {32, 32, 32},
};
*i = 3;
return rv;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-21 15:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-21 15:16 optimization/10185: Wrong code with 3-int-structs & optimization rassahah
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).