/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / STM32 GCC bug with WHILE ?

Username:     
Password:     
             

Forum

# 1   2008-01-14 10:22:18 STM32 GCC bug with WHILE ?

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

STM32 GCC bug with WHILE ?

Try this with GCC !! and no uptimizer
the WHILE is a problem with ARM GCC, sorry
you can try with any variable and any compare system, while simply dont work !!
I can only make while work if I make a while(1) that actually always work..

  unsigned char testcnt=0;

     while(testcnt<100)
     {
       testcnt++;
     }
     testcnt=0;


Thomas Scherrer Denmark webx.dk

Offline

 

# 2   2008-01-14 12:10:19 STM32 GCC bug with WHILE ?

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: STM32 GCC bug with WHILE ?

I just tried with "No Optimization" and it works fine (the loop is executed 100 times).
With optimization, the loop is considered as useless, and just discarded.

Offline

 

# 3   2008-01-14 12:25:47 STM32 GCC bug with WHILE ?

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

Re: STM32 GCC bug with WHILE ?

WIERD !!! I have tried all things I can imagine, it just dont work,
I have also heard from other people tried the same example, and they say it also work for them !!
meybe my GCC compiler dont understand the no uptimize command ?
what can I do to solve this ?


Thomas Scherrer Denmark webx.dk

Offline

 

# 4   2008-01-14 13:00:04 STM32 GCC bug with WHILE ?

lionel
Member
From: Grenoble, France
Registered: 2007-07-24
Posts: 71
Website

Re: STM32 GCC bug with WHILE ?

Hi Thomas,

you should declare your variable testcnt as volatile :

Code:

volatile unsigned char testcnt=0;

Can you try this syntax and tell us if it works better ?
You can also post the command-line used to invoke GCC here to help us understand what's happening.

regards
Lionel

Offline

 

# 5   2008-01-14 13:20:02 STM32 GCC bug with WHILE ?

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

Re: STM32 GCC bug with WHILE ?

it is a problem with the variable declared as unsigned char
in combination with a WHILE loop !
if I declare it as unsinged int, it all works fine


Thomas Scherrer Denmark webx.dk

Offline

 

# 6   2008-01-14 14:04:44 STM32 GCC bug with WHILE ?

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: STM32 GCC bug with WHILE ?

I tried with the exact same code (unsigned char) and it works at my end.

Offline

 

# 7   2008-01-14 16:55:12 STM32 GCC bug with WHILE ?

Squonk
Member
Registered: 2007-10-26
Posts: 10

Re: STM32 GCC bug with WHILE ?

Why don't You compare Your GCC versions?


"The stupidity of mankind and the universe have no end. But in the case of the universe it is not so sure." A. Einstein

Offline

 

# 8   2008-01-15 09:37:58 STM32 GCC bug with WHILE ?

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

Re: STM32 GCC bug with WHILE ?

good point, simply call it with --version to get the info:
arm-none-eabi-gcc (CodeSourcery Sourcery G++ Lite 2007q3-53) 4.2.1
here is mine !! that seems to bug with unsigned chars and while loops,
strange other people can prove this to work !! maybe it is a combination problem, actually caused by something else ?


Thomas Scherrer Denmark webx.dk

Offline

 

# 9   2008-01-15 09:55:59 STM32 GCC bug with WHILE ?

andyc2001
New member
Registered: 2008-01-14
Posts: 4

Re: STM32 GCC bug with WHILE ?

Have you tried using gcc with the "-S" flag and looked at the resultant assembler output.

I have the same version of compiler - and the assembler output appears okay to me.
( but I didn't try any extra flags such as cpu type ).

Maybe you should let us know *exactly* what flags you are issuing to gcc in order to trigger this ?

Andy.

Offline

 

# 10   2008-01-15 10:11:25 STM32 GCC bug with WHILE ?

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: STM32 GCC bug with WHILE ?

I have the same version of the compiler.
At the moment, in RIDE, the "optimization level" option is not a "major" option, and a "make" will not force to recompile a file when you change this option. We will change the attribute of this option to force to recompile.

Now, when the optimization level is set to "Size optimization", no code is generated for this useless loop. But when I set the level to "No Optimization" and I force to recompile the file, the loop is there, and the codecoverage counter reports that it is executed 100 times.

Offline

 

Board footer