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

Re: bug de gcc?



On Fri, Jul 13, 2001 at 06:11:30PM +0200, Loic Le Guyader wrote:
| Essayer ça:
| #include<stdio.h>
| 
| void retenue_f(unsigned long a, unsigned long b, unsigned long
|                c) 
| {
|     unsigned long f;
|     unsigned long long tmp;
| 
|     printf("%lu, %lu, %lu\n", a, b, c);
|     
|     tmp = c+b;
|     f = tmp%10;
|     tmp = (unsigned long long)f + a;
|     while(tmp >= 10)
|             ;
| }
| 
| int main(void)
| {
| 
|     unsigned long r=1, s=2, t=3;
|     
|     retenue_f(r, s, t);
|     return 0;
| }
| 
| Compiler avec gcc -Wall -O2 bug.c -o bug
| Puis faites bug
| Il doit vous afficher 1, 0, 3 au lieu de 1, 2, 3.
| Si quelqu'un peut m'expliquer.
| 
| PS: je n'arrive pas à le réduire encore pour produire l'erreur.
| PS: gcc -v me donne:
| Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
| gcc version 2.95.2 20000220 (Debian GNU/Linux)
[../..]

meme probleme avec , le package gcc de woody ..

Si on remplace le type de tmp "long long" par "long" 
cela marche .

"long long" doit etre l'entier sur 64 bits .

Je me dis la chose suivante :
   faute de frappe 
ou
   tmp doit etre un entier 64 bits 


C'est un bug de compilo , car si on change le niveau d'optimisation ,
le resultat est correct .

--
     ____________________________________________________________
    / Erwan MAS                                                 /\
   | mailto:erwan@mas.nom.fr                                   |_/
___|________________________________________________________   |
\___________________________________________________________\__/



Reply to: