Yes, warnings like that are often generated only when there's enough
optimization for the compiler to notice the potential problem, but not
enough for it to eliminate the problem.

As TinyOS produces monolithic programs that allow significant
interprocedural optimization, it is not impossible that in the 4.5.2
version that the code is entirely optimized away.  That would depend
on what's done with the returned value.

Can you confirm that, in the generated code, there is actual reference
to the variable that was not initialized?

(BTW: Has somebody packaged msgcc as 4.5.3?  It's still 4.5.2, but
this is the second reference to that version I've seen from the TinyOS
community.)

Peter

On Wed, Jul 6, 2011 at 5:41 AM, Michiel Konstapel <m.konsta...@sownet.nl> wrote:
> Here's a (nesC) function in which I forgot to initialize the "count"
> variable to zero:
>
>        command uint16_t ChainRouting.countGoodNeighbours(uint8_t
> destination) {
>                uint8_t count;
>                uint8_t i;
>                for (i=0; i<ROUTING_TABLE_SIZE; i++) {
>                        routing_table_entry_t* entry = &routingTable[i];
>                        uint16_t etx = (destination ==
> DESTINATION_FIXED) ? entry->etxUp : entry->etxDown;
>                        if (!entry->valid) continue;
>                        if (entry->bidir && etx < MAX_ETX &&
> decentSignal(entry) && isRecent(entry)) {
>                                count++;
>                        }
>                }
>
>                return count;
>        }
>
> mspgcc 3.2.3 correctly warns:
> ../../routing/ChainRoutingP.nc:281: warning: `count' might be used
> uninitialized in this function
>
> but 4.5.3 doesn't complain at all. However, in a tiny test program both
> produce the warning:
>
> #include "io.h"
> char foo[10];
> int main() {
>        int count;
>        int i;
>        for (i=0 ; i<10; i++) {
>                if (foo[i] == 'a') count++;
>        }
>
>        return count;
> }
>
> It only warns if optimization is enabled (-Os in my case). Is that how
> it's supposed to work? I've verified the -Os flag is present when
> compiling the TinyOS program, with both compilers. Any ideas on why the
> old version catches it and the new one doesn't? I can produce loads more
> output and a copy of app.c if required.
>
> Regards,
> Michiel
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to