This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: GCC 3.1/3.1.1/3.2(?) bug


Just wanted to kick this off to you guys, in case you haven't 
discovered it already.  It appears to affect all versions of gcc 
>=3.1.  The thread about this really starts here:

http://archive.linuxfromscratch.org/mail-archives/lfs-dev/2002/08/0350.html

----------  Forwarded Message  ----------

Subject: Re: kbd miscompilation - found out why...
Date: Tue, 13 Aug 2002 05:30:03 -0500
From: Kelledin <kelledin+LFS@skarpsey.dyndns.org>
To: lfs-dev@linuxfromscratch.org

The good news, i found the problem.

The bad news, it's a gcc bug. =(

The problem appears to be that when a struct with a static char
array (either signed or unsigned char) is passed to a function
(not a struct pointer, but the struct itself, is passed to the
function), the contents get miscopied.  This only happens if the
app is compiled for cpu i686 or greater; optimization level
appears to make no difference.  It does not appear to happen
with static arrays of other types, such as int or float.

Test case is below:

--Begin
 testcase.c-----------------------------------------------
 #include <stdio.h>

struct abba {
    char str[128];
};

void test(struct abba ke)
{
    printf("%s\n", ke.str);
}

int main()
{
    struct abba ke;

    strcpy(ke.str, "DOH");
    test(ke);
}
--End
 testcase.c-------------------------------------------------

[ root@valhalla /usr/src ] # gcc -O2 -march=i686 testcase.c -o \
testcase
[ root@valhalla /usr/src ] # ./testcase
ج@`G@`a    @@8K@7@X/
[ root@valhalla /usr/src ] # gcc -O2 -march=i486 testcase.c -o \
testcase
[ root@valhalla /usr/src ] # ./testcase
DOH
[ root@valhalla /usr/src ] # gcc -march=i686 testcase.c -o \
testcase
[ root@valhalla /usr/src ] # ./testcase
G@`a        @@8K@7@X/


*sign* Gotta love dem gcc bugs.

--
Kelledin
"If a server crashes in a server farm and no one pings it, does
it still cost four figures to fix?"

--
Unsubscribe: send email to listar@linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the
 message

-------------------------------------------------------

-- 
Kelledin
"If a server crashes in a server farm and no one pings it, does 
it still cost four figures to fix?"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]