Hi,
the compiler output message reads a bit confusing. I'm no expert in gcc internals but as for your code..

Yann Ramin wrote:
The following code produces the following error. It doesn't trigger the error if the global is not marked volatile. Any ideas?



gcc-current from CVS as of a week ago
gcc-3.4.4
Linux

Code:
volatile uint32_t t;

int main() {
  int count;
  count = count << 3;

The local variable count is uninitialized and used as rvalue. This is no syntactical "error" but a semantical one. It leads to undefined results.


  uint32_t g = count;

Did you tell your compiler to compile C++ code? In C you cannot declare/define new local variables inside a block after the first instructions (you have to omit the preceding line count = count << 3;). -> This is a syntactical error! A possible reason for the difference with or without volatile is the optimization: The assignment of t is the last executed line of code. t is not used and can be optimized away and so can the last line. As a next step you can see that if you omit the last line g is not used anywhere else and thus can be optimized away. (Finally for the same reason also count can be omitted and main() is ... empty). The situation differs if you plan to access t from out of main's control flow (i.e. from an ISR). In this case all the other lines are needed too. You use volatile to inform the compiler about this very fact.
Regards

Arnd-Hendrik


  t = g | t;
}


Error:

msp430-gcc -g -mmcu=msp430x1611 -o main main.c
main.c: In function `main':
main.c:61: error: unrecognizable insn:
(insn 75 74 28 0 main.c:27 (set:HI (subreg:HI (mem/v/f:SI (symbol_ref:HI ("t") <var_decl 0xb7cfbaf8 t>) [0 t+0 S4 A16]) 2) (ior:HI (subreg:HI (mem/v/f:SI (symbol_ref:HI ("t") <var_decl 0xb7cfbaf8 t>) [0 t+0 S4 A16]) 2)
            (mem/f:HI (plus:HI (reg/f:HI 4 r4)
                    (const_int 4 [0x4])) [0 g+2 S2 A16]))) -1 (nil)
    (nil))
main.c:61: internal compiler error: in extract_insn, at recog.c:2083
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [main] Error 1


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users



Reply via email to