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

Bug#419562: marked as done (gcc-4.1: dummy scanf needed)



Your message dated Sun, 16 Sep 2007 19:18:39 +0200
with message-id <18157.25967.515157.833215@gargle.gargle.HOWL>
and subject line Bug#419562: gcc-4.1: dummy scanf needed
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
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: 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


--- End Message ---
--- Begin Message ---
> You can close the bug.

done


--- End Message ---

Reply to: