Bug#443576: gcc-4.2: -O2 generates wrong code

2007-09-22 Thread Ludovic Rousseau
Package: gcc-4.2
Version: 4.2.1-5
Severity: critical
Justification: breaks unrelated software


Hello,

I think I found a bug in gcc-4.2. The bug is easy to reproduce. I have
it under sid and also under testing.

I provide a simple test program (gint_to_pointer.c):
#include 

int main(void)
{
   int i, j;

   for (i=0; i<6; i++)
   {
   j = i-1;
   printf("%d %d\n", j, (void *)(j));
   }
}


When compiled with make gint_to_pointer CFLAGS="-O0" the execution gives:
-1 -1
0 0
1 1
2 2
3 3
4 4


But when compiled with make gint_to_pointer CFLAGS="-O2" the execution gives:
-1 -1
0 -1
1 -1
2 -1
3 -1
4 -1

I generated the assembly for the two cases.
With -O0
.file   "gint_to_pointer.c"
.section.rodata
.LC0:
.string "%d %d\n"
.text
.globl main
.type   main, @function
main:
leal4(%esp), %ecx
andl$-16, %esp
pushl   -4(%ecx)
pushl   %ebp
movl%esp, %ebp
pushl   %ecx
subl$36, %esp
movl$0, -12(%ebp)
jmp .L2
.L3:
movl-12(%ebp), %eax
subl$1, %eax
movl%eax, -8(%ebp)
movl-8(%ebp), %eax
movl%eax, 8(%esp)
movl-8(%ebp), %eax
movl%eax, 4(%esp)
movl$.LC0, (%esp)
callprintf
addl$1, -12(%ebp)
.L2:
cmpl$5, -12(%ebp)
jle .L3
addl$36, %esp
popl%ecx
popl%ebp
leal-4(%ecx), %esp
ret
.size   main, .-main
.ident  "GCC: (GNU) 4.2.1 (Debian 4.2.1-5)"
.section.note.GNU-stack,"",@progbits



with -O2:
.file   "gint_to_pointer.c"
.section.rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d %d\n"
.text
.p2align 4,,15
.globl main
.type   main, @function
main:
leal4(%esp), %ecx
andl$-16, %esp
pushl   -4(%ecx)
pushl   %ebp
movl%esp, %ebp
pushl   %ebx
xorl%ebx, %ebx
pushl   %ecx
subl$16, %esp
movl$-1, 8(%esp)
movl$-1, 4(%esp)
movl$.LC0, (%esp)
callprintf
.p2align 4,,7
.L2:
movl%ebx, 4(%esp)
addl$1, %ebx
movl$-1, 8(%esp)
movl$.LC0, (%esp)
callprintf
cmpl$5, %ebx
jne .L2
addl$16, %esp
popl%ecx
popl%ebx
popl%ebp
leal-4(%ecx), %esp
ret
.size   main, .-main
.ident  "GCC: (GNU) 4.2.1 (Debian 4.2.1-5)"
.section.note.GNU-stack,"",@progbits


I do not read i386 assembly so can't help spot the bug.

Notes:
I have no problem if I use "i" or "i+1" instead of "i-1".
I have no problem if I start the loop at 1 instead of 0.


I discovered the bug because of my package does not work correctly anymore.
Other packages compiled with gcc-4.2 may also fail in very obscure ways.

Thanks,

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing'), (90, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-2-686 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gcc-4.2 depends on:
ii  binutils  2.18-1 The GNU assembler, linker and bina
ii  cpp-4.2   4.2.1-5The GNU C preprocessor
ii  gcc-4.2-base  4.2.1-5The GNU Compiler Collection (base 
ii  libc6 2.6.1-1+b1 GNU C Library: Shared libraries
ii  libgcc1   1:4.2.1-5  GCC support library
ii  libgomp1  4.2.1-5GCC OpenMP (GOMP) support library

Versions of packages gcc-4.2 recommends:
ii  libc6-dev 2.6.1-1+b1 GNU C Library: Development Librari
pn  libmudflap0-4.2-dev(no description available)

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#443576: Strict aliasing problem

2007-09-22 Thread Phil Endecott

I think I found a bug in gcc-4.2



int i, j;
printf("%d %d\n", j, (void *)(j));


This looks like a strict-aliasing issue to me; you're casting from an 
int to a void*, which is undefined.  Did you get any warnings?  (Did 
you compile with warnings enabled? -Wstrict-aliasing?)  Investigate the 
-f[no]strict-aliasing options.


Regards,

Phil.







--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#438816: gcc-multilib: Use case

2007-09-22 Thread Sam Woodhead
Package: gcc-multilib
Version: 4:4.2.1-6
Followup-For: Bug #438816

This would be very useful when building kernel modules that do nasty
things (for example on my system I have 4gb ram - so use a 64 bit kernel
but I still want a 32 bit userland) Most can be made to build but with
the appropriate arch links it would be much easier (fighting with kqemu
at the moment) something like how the links are in the uclibc-toolchain
package would be brilliant.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.23-h3-2 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-multilib depends on:
ii  cpp   4:4.2.1-6  The GNU C preprocessor (cpp)
ii  gcc   4:4.2.1-6  The GNU C compiler
ii  gcc-4.2-multilib  4.2.1-5The GNU C compiler (multilib files

gcc-multilib recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



[bts-link] source package gcc-4.2

2007-09-22 Thread bts-link-upstream
#
# bts-link upstream status pull for source package gcc-4.2
# see http://lists.debian.org/debian-devel-announce/2006/05/msg1.html
#

user [EMAIL PROTECTED]

# remote status report for #440545
#  * http://gcc.gnu.org/PR33381
#  * remote status changed: NEW -> ASSIGNED
usertags 440545 - status-NEW
usertags 440545 + status-ASSIGNED

thanks