Bug in while() intrinsic ?

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

 



	Hello,

	I'm trying to debug a subroutine in a very long program. You can find
this GPL'd program at http://www.rpl2.net/.

	In src/instructions_e2.c, line 1250, I have written :

    l_element_pile_systeme = (*s_etat_processus).l_base_pile_systeme;
    presence_boucle = d_faux;
    drapeau_boucle_definie = d_faux;

    while((l_element_pile_systeme != NULL) &&
		(presence_boucle == 	d_faux))
    {
printf("Boucle %d\n", presence_boucle);
        if ((strcmp((*l_element_pile_systeme).type_cloture, "START")
		== 0) || (strcmp((*l_element_pile_systeme)
		.type_cloture, "FOR") == 0))
        {
printf("Là\n");
            presence_boucle = d_vrai;
            drapeau_boucle_definie = d_vrai;
        }
        else if ((strcmp((*l_element_pile_systeme).type_cloture, "DO")
		== 0) || (strcmp((*l_element_pile_systeme)
		.type_cloture, "WHILE") == 0))
        {
printf("Ici\n");
            presence_boucle = d_vrai;
            drapeau_boucle_definie = d_faux;
        }

printf("<%s> %d\n", (*l_element_pile_systeme).type_cloture,
presence_boucle);
        l_element_pile_systeme = (*l_element_pile_systeme).suivant;
printf("<> %d\n", presence_boucle);
    }

    if (presence_boucle == d_faux)
    {
        printf("Paf\n");
        (*s_etat_processus).erreur_execution = d_ex_exit_hors_boucle;
        return;
    }

	presence_boucle and drapeau_boucle_definie are both unsigned char.
d_vrai is equal to (unsigned char) (-1) and d_faux to (unsigned char) 0.
l_element_pile_systeme is a structure that contains a field 'suivant'
that is a pointer to next element. type_cloture field is a char[6].

	When I run this code, I obtain :

Boucle 0
<IF> 0
<> 0
Boucle 0
Ici
<WHILE> 255
<> 255
Boucle 0 <--- I don't understand why this variable is modified !
<> 0
<> 0
Boucle 0
<> 0
<> 0
Paf
+++Erreur : Instruction 'EXIT' hors d'une boucle [31196]

	If I have written :

while((l_element_pile_systeme != NULL) && (presence_boucle = d_faux))
{
	...
}

I could understand... But I have written :

while((l_element_pile_systeme != NULL) && (presence_boucle == d_faux))
{
	...
}

	I have tested with gcc-4.3 from debian, gcc-4.4.1 on both linux/sparc
and linux/amd64. On both systems, I have tried -O2 and -O3 flags without
any difference.

	To reproduce : build program
(http://www.rpl2.net/download/rpl-4.0.6.tar.bz2) and execute the
following script :

#!/usr/local/bin/rpl -csp

MAIN
<<
    "toto"
    -> ADRESSE
    <<
        1 1
        -> J N
        <<
            1 ADRESSE size for I
                while
                    ADRESSE I dup sub " " same
                repeat
                    'I' incr

                    if
                        I ADRESSE size >
                    then
                        exit
                    end
                end

                I 'J' sto

                while
                    ADRESSE I dup sub " " same not
                repeat
                    'I' incr

                    if
                        I ADRESSE size >
                    then
                        exit
                    end
                end

                ADRESSE J I 1 - sub
                'N' incr
            next
        >>

        clmf
    >>


	Any idea ?

	Regards,

	JKB


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux