Package: gcc-4.1 Version: 4.1.1-21 Severity: normal
When I try to compile the following code, I need the fourth scanf("%i",&k); if not, the expo variable equals 0. This bug appears in gcc 4.0 and gcc 4.1 but not in gcc 3.3. *** Code *** /*#include <math.h>*/ #include <stdio.h> #include <stdlib.h> #include <time.h> int puissance(int N, int p, int e) /* p^e modulo N*/ { int z, i; z=1; for (i=1;i<=e;i++) { z*=p; z%=N; } return z; } int main(int argc, char *argv[]) { srand (time (NULL)); int base,pi,expo,k,pie; char message; int premier, deuxieme; /*Premier et deuxième nombres transmis*/ printf("Entrer la base "); scanf("%d",&base); printf("Entrer la perturbation "); scanf("%d",&pi); printf("Entrer l’exposant "); scanf("%d",&expo); /* scanf("%i",&k);*/ /* This scanf is mandatory in gcc 4, if not expo is 0, even if you force it to be 11 */ /* expo=11;*/ /* Commented like this, expo == 0 in gcc 4 but not in gcc 3 */ while(1) { printf("Entrer la lettre à coder "); scanf("%s",&message); k=1+(rand() % (base-1)); premier=puissance(base,pi,k); printf("%i\n",expo); pie=puissance(base,pi,expo); printf("pi^e=%i\n",pie); deuxieme=((message-96) * puissance(base,pie,k)) % base; printf("Le code est (%i,%i).\n",premier,deuxieme); } return 0; } *** End of code *** -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.16-2-686-smp (SMP w/1 CPU core) Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages gcc-4.1 depends on: ii binutils 2.17-3 The GNU assembler, linker and bina ii cpp-4.1 4.1.1-21 The GNU C preprocessor ii gcc-4.1-base 4.1.1-21 The GNU Compiler Collection (base ii libc6 2.3.6.ds1-13 GNU C Library: Shared libraries ii libgcc1 1:4.1.1-21 GCC support library ii libssp0 4.1.1-21 GCC stack smashing protection libr Versions of packages gcc-4.1 recommends: ii libc6-dev 2.3.6.ds1-13 GNU C Library: Development Librari ii libmudflap0-dev 4.1.1-21 GCC mudflap support libraries (dev -- no debconf information