> 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.
Ack. > 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. The returned value is definitely used - I'm currently blinking a LED 'numNeighbours' of times, and the result is correct (because the memory happened to be zero?) > Can you confirm that, in the generated code, there is actual reference > to the variable that was not initialized? Let me check... It ends up inlined several levels deep, so I couldn't find it in the objdump output. So I figured I'd __noinline__ the fuction, and hey: I do get the warning. C keeps scaring me... Does this mean that the compiler assumes I want it zeroed, and can prove it will be zero in the inlined code? Or does it assume I don't care, but it only warns me about it in some cases? Or can it simply no longer detect the error if the function is inlined? So, at no optimization, or too much optimization, you lose your warnings? > (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.) I've got 4.5.2 which I compiled from source, but my coworker installed 4.5.3 as a debian package and since that was newer, I figured I'd use that to verify the bug (if it is one). Here's the version info: $ apt-cache show gcc-msp430 Package: gcc-msp430 Version: 4.5.3~mspgcc-4.5.2-20110612-1 Installed-Size: 26652 Maintainer: Luca Bruno <lu...@debian.org> Architecture: amd64 Depends: libc6 (>= 2.11), libgmp10, libmpc2, libmpfr4, zlib1g (>= 1:1.1.4), msp430mcu, binutils-msp430 (>= 2.21~) Recommends: msp430-libc Description: The GNU C compiler (cross compiler for MSP430) This is the GNU C compiler, a fairly portable optimizing compiler for C for TI's MSP430 architecture. This package is primarily for MSP430 developers and cross-compilers and is not needed by normal users. Section: devel Priority: extra Filename: pool/main/g/gcc-msp430/gcc-msp430_4.5.3~mspgcc-4.5.2-20110612-1_amd64.deb Size: 9887062 MD5sum: c7283cf69a4d1787de9d50145973eb9f SHA1: 4a7ccadd563be2aa7dc61d5d9b3a71b58971180d SHA256: cf9f555fd24151dc32279fc3b4523025fc0a65395aa0d08c7d508a8ddf134381 $ msp430-gcc --version msp430-gcc (GCC) 4.5.3 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Best, Michiel > 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