This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
x86 C compiler problem 2.95.2 (latest snapshot may be ok)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: x86 C compiler problem 2.95.2 (latest snapshot may be ok)
- From: Urban Widmark <urban at svenskatest dot se>
- Date: Tue, 28 Mar 2000 22:37:27 +0200 (CEST)
Hello
While doing some work on the linux via-rhine network driver I accidentally
wrote some code that breaks in gcc 2.95.2 (-O2), but works in egcs-1.1.2
and in gcc 2.95.2 (-O).
To make the attached testprogram fail, I compile as:
/usr/local/gcc2.95.2/bin/gcc -O2 -o aa.gcc via-rhine.2.3.99.c
Expected output is:
0: 00000000 08049660 00000000 40009f0e
1: 00000000 08049660 00000000 40009f1e
2: 00000000 08049660 00000000 40009f2e
3: 00000000 08049660 00000000 40009f3e
...
but the failing code generates:
0: 00000000 bffffb20 00000000 400126c0
1: 00000000 00000000 00000000 00000000 <-!
2: 00000000 bffffb20 00000000 400126d0
3: 00000000 bffffb20 00000000 400126e0
This is on Linux 2.3.99-pre3, RH6.1, x86 SMP, and also seen on K6-2 450
and Celeron 300A.
When testing the attached problem with the latest compiler snapshot on
http://www.codesourcery.com/gcc-compile.html (cool!)
I could not see the problem.
This is the part that fails with 2.95.2, but the testprogram contains a
few more items to make it work.
for (i = 0; i < 16; i++) {
np->rx_ring[i].rx_status = 0;
np->rx_ring[i].desc_length = np->rx_buf_sz;
np->rx_ring[i].next_desc =
np->rx_ring_dma + sizeof(struct rx_desc)*(i+1);
np->rx_skbuff[i] = 0;
}
np->rx_ring[i-1].next_desc = np->rx_ring_dma;
Changing the loop to use a separate variable for setting np->rx_ring_dma
(next += sizeof(struct rx_desc)) generates working code with gcc 2.95.2
and -O2.
/Urban
via-rhine.2.3.99.i.gz