Optimization or bug ?

Hello every body,

First of all excuse me for my french spelling mistake

The following code give me headache.
I have declared timer interrupt routine which decrement a T1 variable every 1/10s.
This routine also turn ON and OFF the famous pin13 LED just for verification. At the end of the time, it's mean when T1 is 0 the flag t1timeout is turned ON the LED is turned OFF.

All off this works fine but:
In the loop() if i do that
do {Serial.println(T1,DEC);} while(t1timeout==false);
Serial.println("timeout");
I could see timeout on serial monitor at the end of time

but if i do that
do {++x;} while(t1timeout==false);
Serial.println("timeout");
I can't see anything.

Do you have some ideas ??
Many thanks

#define T1TIME 100

boolean T1run = false; //Timer 1 started
boolean t1timeout = false;//timer 1 time elapsed flag

int T1 = T1TIME; //10 seconds
int x = 0; // nothing
int retry = 0; //flag for blink
int pinled =13; //no comment

ISR(TIMER1_COMPA_vect ){ //timer1 interrupt routine
if (T1run) {
if (--T1==0) {
T1run=false;
t1timeout = true; // if timer1 elapsed time then TRUE
} //blinking LED ON 1/10s OFF 1/10s
if (retry == 0) {
digitalWrite( pinled , HIGH);
retry = 1;
}
else {
digitalWrite(pinled , LOW);
retry = 0;
}
}
}

void T1start(boolean etat){
T1 = T1TIME;
T1run = etat;
t1timeout = false;
}

void setup_timer(){ //parametre le timer 1 pour envoyer des tick tous les 1/10 de seconde
TCCR1A = B00000000;
TCCR1B = B00001011; //prescaler 1/64
TCCR1C = B00000000;
OCR1A = 25000; //with prescaler of 64 this value equals 1/10 seconde
TIMSK1 = B00000010; //interruption compare enable
sei(); //enable interruptions
}

void setup(){
Serial.begin(9600);
setup_timer();
pinMode(pinled, OUTPUT);
}

void loop(){
T1start(true);
// here is the stuff, if you let as is you will see timeout on serial monitor after 10 seconds
//if you uncomment the following line and comment the next, nothing happen. No timeout display !!
//in both case the blinking LED confirm timer beat

do {++x;} while(t1timeout==false);
//do {Serial.println(T1,DEC);} while(t1timeout==false);

Serial.println("timeout"); //this line
while(1==1);
}

Every variable accessed in both an isr and the main loop should be declared volatile.

Merde, pourtant je le savais ]:D.Once again no mystery

Thanks again it works.