[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#419562: gcc-4.1: dummy scanf needed

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;
  for (i=1;i<=e;i++)
  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 ");
  printf("Entrer la perturbation ");
  printf("Entrer l’exposant ");
/*  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 */
    printf("Entrer la lettre à coder ");
    k=1+(rand() % (base-1));
    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: LANG=fr_FR.UTF-8@euro, LC_CTYPE=fr_FR.UTF-8@euro (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

Reply to: